Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Trapping Excel error messages in Powershell Scheduled scripts

$
0
0

Hi Dave
Thanks for your reply. I was hoping there might be some variable that Excel uses to store the error code or message.

This is the contents of $Error[0]

Remove-Variable : Cannot find a variable with name ‘UserWorkBook’.
At C:\inetpub\ftproot\XML_Convert.ps1:71 char:13
+ Remove-Variable UserWorkBook
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (UserWorkBook:String) [Remove-Variable], ItemNotFoundException

The first error generated was:

Exception calling “Open” with “1″ argument(s): “Open method of Workbooks class failed”
At C:\inetpub\ftproot\XML_Convert.ps1:59 char:13
+ $UserWorkBook = $objExcel.Workbooks.Open($strInputFile)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation

If I set DisplayAlerts to $True, I get a message box titled “Problems during load” and the word “Worksheets” in the box.

Regards

David


Viewing all articles
Browse latest Browse all 13067

Latest Images

Trending Articles



Latest Images