Hi fellows,
I’m trying to automate the refreshing of data in my Excel Reports. Here the script:
$ExcelApp = new-object -ComObject Excel.Application
$ExcelApp.Visible = $false
$ExcelApp.DisplayAlerts = $false
$Workbook = $ExcelApp.Workbooks.Open("RefreshTest.xlsx", 3, $false, 5, $null, $null, $true)
$Workbook.RefreshAll()
$Workbook.Save()
$ExcelApp.Quit()
The script is fine, but when I try to run it directly it shows me the following error:
Method invocation failed because [System.__ComObject] doesn't contain a method named 'Save'.
At line:7 char:15
+ $Workbook.Save <<<< ()
+ CategoryInfo : InvalidOperation: (Save:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Curiously, if I run just the top part of the script (before the Save method), then call the Save method after, it works fine.
Could you help me? It was tested against PowerShell V1 and PowerShell V2 (the bits installed with Win7 Beta).
Best regards, Rafa