R
reverse_atomic_roger
I'm trying to write a powershell script that will fill in the first cell of a
spreadsheet.
So far I have this...
$excel = new-object -comobject excel.application
$excel.visible = $true
$path = "\\cse2k303\pgreer\WindowsPowerShell\Scripts\test.xls"
#use psbase to open new workbook as excel doesn't like UK regional settings...
$ci = [System.Globalization.CultureInfo]'en-us'
$book = $excel.workbooks.psbase.gettype().InvokeMember("Open",
[Reflection.BindingFlags]::InvokeMethod, $null, $excel.workbooks, $path, $ci)
$sheet = $book.worksheets.item(1)
$sheet.cells.item(1,1).value() = "Testing, testing, 1, 2, 3, 4."
The script seems to work fine until the last line, when powershell gives
this error;
Exception setting "Value": "Exception from HRESULT: 0x800A03EC"
At \\cse2k303\pgreer\WindowsPowerShell\Scripts\Excel2.ps1:19 char:29
+ $sheet.cells.item(2,2).value( <<<< ) = "Testing, testing, 1, 2, 3, 4."
I've tried the last line like this(without the ".value")...
$sheet.cells.item(1,1) = "Testing, testing, 1, 2, 3, 4."
but I get a similar error...
Exception setting "Item": "Exception from HRESULT: 0x800A03EC"
At \\cse2k303\pgreer\WindowsPowerShell\Scripts\Excel2.ps1:19 char:18
+ $sheet.cells.item( <<<< 2,2) = "Testing, testing, 1, 2, 3, 4."
I've searched the 'net for some time, but to no avail. Does anyone have any
suggestions for a fix?
spreadsheet.
So far I have this...
$excel = new-object -comobject excel.application
$excel.visible = $true
$path = "\\cse2k303\pgreer\WindowsPowerShell\Scripts\test.xls"
#use psbase to open new workbook as excel doesn't like UK regional settings...
$ci = [System.Globalization.CultureInfo]'en-us'
$book = $excel.workbooks.psbase.gettype().InvokeMember("Open",
[Reflection.BindingFlags]::InvokeMethod, $null, $excel.workbooks, $path, $ci)
$sheet = $book.worksheets.item(1)
$sheet.cells.item(1,1).value() = "Testing, testing, 1, 2, 3, 4."
The script seems to work fine until the last line, when powershell gives
this error;
Exception setting "Value": "Exception from HRESULT: 0x800A03EC"
At \\cse2k303\pgreer\WindowsPowerShell\Scripts\Excel2.ps1:19 char:29
+ $sheet.cells.item(2,2).value( <<<< ) = "Testing, testing, 1, 2, 3, 4."
I've tried the last line like this(without the ".value")...
$sheet.cells.item(1,1) = "Testing, testing, 1, 2, 3, 4."
but I get a similar error...
Exception setting "Item": "Exception from HRESULT: 0x800A03EC"
At \\cse2k303\pgreer\WindowsPowerShell\Scripts\Excel2.ps1:19 char:18
+ $sheet.cells.item( <<<< 2,2) = "Testing, testing, 1, 2, 3, 4."
I've searched the 'net for some time, but to no avail. Does anyone have any
suggestions for a fix?