PowerShell: unable to get the open property of the workbooks class
Andrew Mclaughlin
So I try to open an Excel file with PowerShell. But I got this error message: "unable to get the open property of the workbooks class".
$dirPath = ("C:\Users\localadmin\OneDrive\DailyReports\")
$manFile = Get-ChildItem -Path $dirPath -Recurse -Filter "*MANSUM*"
$manPath = $manFile.Fullname
$excel = New-Object -ComObject Excel.Application
$excel.DisplayAlerts = $false
$manWB = $excel.Workbooks.Open($manPath)How can I fix this error?
The full path ($manPath) is correct.
Running Windows 10 Pro, Excel 2016
11 Answer
Here's a solution:
Need to create folder and provide proper access rights.
・Windows 2008 Server x64
Please make this folder.
C:\Windows\SysWOW64\config\systemprofile\Desktop
・Windows 2008 Server x86
Please make this folder.
C:\Windows\System32\config\systemprofile\Desktop
Refer:
1