I need solving for error at line 13, besides there are two warning/notes. The script is running but with these fails.
# xls_test.ps1
function Invoke() {
param([object]$m,
[string]$method,
$parameters)
$m.PSBase.GetType().InvokeMember($method, `
[Reflection.BindingFlags]::InvokeMethod, `
$null, $m, $parameters,$ciUS)
}
$ciUS = [System.Globalization.CultureInfo]'en-US'
$objExcel = New-object -comObject Excel.Application
$objExcel.visible = $True
$objWorkbook = Invoke $objExcel.Workbooks Add
$objWorksheet = $objWorkbook.worksheets | where {$_.name -eq "sheet1"}
$objWorksheet.cells.item(1,1).formulaLocal = "Value in cell A1"
[void]$objWorksheet.range("a1").addComment()
[void]$objWorksheet.range("a1").comment.visible = "$False ..."
## No text found in comment !
$range = $objWorksheet.activeCell.entireColumn
$range.autoFit
## nothing has changed !
$range = $objWorksheet.range("b1:b1")
$range.cells = "ColB Row1"
$range.font.size = 24
## Property 'size' cannot be found on this object;
## make sure it exists and is settable. `
## At C:\scripts\xls_test.ps1:32 char:13 + $range.font.s <<<< ize = 24
Invoke $objWorkbook SaveAs "c:\scripts\XLS_test.xls" > $null
Invoke $objWorkbook Close 0 > $null
$objExcel.quit()
# xls_test.ps1
function Invoke() {
param([object]$m,
[string]$method,
$parameters)
$m.PSBase.GetType().InvokeMember($method, `
[Reflection.BindingFlags]::InvokeMethod, `
$null, $m, $parameters,$ciUS)
}
$ciUS = [System.Globalization.CultureInfo]'en-US'
$objExcel = New-object -comObject Excel.Application
$objExcel.visible = $True
$objWorkbook = Invoke $objExcel.Workbooks Add
$objWorksheet = $objWorkbook.worksheets | where {$_.name -eq "sheet1"}
$objWorksheet.cells.item(1,1).formulaLocal = "Value in cell A1"
[void]$objWorksheet.range("a1").addComment()
[void]$objWorksheet.range("a1").comment.visible = "$False ..."
## No text found in comment !
$range = $objWorksheet.activeCell.entireColumn
$range.autoFit
## nothing has changed !
$range = $objWorksheet.range("b1:b1")
$range.cells = "ColB Row1"
$range.font.size = 24
## Property 'size' cannot be found on this object;
## make sure it exists and is settable. `
## At C:\scripts\xls_test.ps1:32 char:13 + $range.font.s <<<< ize = 24
Invoke $objWorkbook SaveAs "c:\scripts\XLS_test.xls" > $null
Invoke $objWorkbook Close 0 > $null
$objExcel.quit()