$code = {
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $true
$workbook1 = $excel.Workbooks.Add$$
# write into cell B5 $column 2, line 5$:
$workbook1.ActiveSheet.Cells.Item$5,2$= "I can write directly to cells!"
# read cell content
$content = $workbook1.ActiveSheet.Cells.Item$5,2$.Text "Cell B5 content: $content"
}
this code does not work, especifically:
$workbook1.ActiveSheet.Cells.Item$5,2$= "I can write directly to cells!"
this line gives me:
Cannot index into a null array.
At line:1 char:28
+ $workbook1.activesheet.cells.item[ <<<< 5,2]="things"
+ CategoryInfo : InvalidOperation: (System.Object[]:Object[]) [], Runti
meException
+ FullyQualifiedErrorId : NullArray
I'm using the Office 2010 version of excell
PS: I copied this code section from your site and changed the $ to either [ or ( where necessary.