Hello,
I’m working on a project to encrypt PDF files from a list in excel. I have been unable to open the .XLSX with the following error
PS C:\WINDOWS\system32> C:\PDF\Script1.ps1 GAC Version Location --- ------- -------- False v2.0.50727 c:\pdf\ITextSharp.dll Confirm Variables---> Excel-instance:Microsoft.Office.Interop.Excel.ApplicationClass FilePath:C:\pdf\Book1.xlsx <You cannot call a method on a null-valued expression. At C:\PDF\Script1.ps1:39 char:1 + $wb = $excel.Workbooks.Open($FilePath) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull The property 'sheets' cannot be found on this object. Verify that the property exists. At C:\PDF\Script1.ps1:42 char:12 + for ($i=1; $i -le $wb.sheets.count; $i++) + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException + FullyQualifiedErrorId : PropertyNotFoundStrict You cannot call a method on a null-valued expression. At C:\PDF\Script1.ps1:70 char:1 + $excel.Workbooks.Close() + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull ________________________________ Original Script: PS C:\WINDOWS\system32> C:\PDF\Script1.ps1 GAC Version Location --- ------- -------- False v2.0.50727 c:\pdf\ITextSharp.dll Confirm Variables---> Excel-instance:Microsoft.Office.Interop.Excel.ApplicationClass FilePath:C:\pdf\Book1.xlsx You cannot call a method on a null-valued expression. At C:\PDF\Script1.ps1:39 char:1 + $wb = $excel.Workbooks.Open($FilePath) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull The property 'sheets' cannot be found on this object. Verify that the property exists. At C:\PDF\Script1.ps1:42 char:12 + for ($i=1; $i -le $wb.sheets.count; $i++) + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException + FullyQualifiedErrorId : PropertyNotFoundStrict You cannot call a method on a null-valued expression. At C:\PDF\Script1.ps1:70 char:1 + $excel.Workbooks.Close() + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Any assistance will be appreciated. Thanks