Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
PS C:\WINDOWS\system32> C:\Convert-ToPDF.PS1
1:Processing C:\Logs\MultipleMembers.xls
You cannot call a method on a null-valued expression.
At C:\Convert-ToPDF.PS1:16 char:9
+ $wb = $xl.Documents.Open($_.FullName)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Method invocation failed because [System.IO.FileInfo] does not contain a method named 'ExportAsFixedFormat'.
At C:\Convert-ToPDF.PS1:17 char:9
+ $wb.ExportAsFixedFormat([Microsoft.Office.Interop.Excel.XlFix ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.IO.FileInfo] does not contain a method named 'Close'.
At C:\Convert-ToPDF.PS1:19 char:9
+ $wb.Close()
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
2:Processing C:\Logs\OnPremise.xlsx
You cannot call a method on a null-valued expression.
At C:\Convert-ToPDF.PS1:16 char:9
+ $wb = $xl.Documents.Open($_.FullName)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Method invocation failed because [System.IO.FileInfo] does not contain a method named 'ExportAsFixedFormat'.
At C:\Convert-ToPDF.PS1:17 char:9
+ $wb.ExportAsFixedFormat([Microsoft.Office.Interop.Excel.XlFix ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [System.IO.FileInfo] does not contain a method named 'Close'.
At C:\Convert-ToPDF.PS1:19 char:9
+ $wb.Close()
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Exception calling "ReleaseComObject" with "1" argument(s): "The object's type must be __ComObject or derived from __ComObject.
Parameter name: o"
At C:\Convert-ToPDF.PS1:25 char:1
+ [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wb)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
PS C:\WINDOWS\system32> C:\Logs\Convert-ToPDF.PS1
1:Processing C:\Logs\MultipleMembers.xls
You cannot call a method on a null-valued expression.
2:Processing C:\Logs\OnPremise.xlsx
You cannot call a method on a null-valued expression.
Exception calling "ReleaseComObject" with "1" argument(s): "The object's type must be __ComObject or derived from __ComObject.
Parameter name: o"
At C:\Convert-ToPDF.PS1:29 char:1
+ [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wb)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
0
Why is that still happening considering the script can and only look for .XLS and .XLSX files?
You seem to have issue with Excel. Have you tried to restart your system. I suspet you heav 100s of copies of Excel running hidden due to all of the errors.
This topic is 4 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.