所以我嘗試使用 PowerShell 開啟 Excel 檔案。但我收到此錯誤訊息:「無法取得工作簿類別的開放屬性」。
$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)
我該如何修復這個錯誤?
完整路徑 ( $manPath
) 是正確的。
運行 Windows 10 專業版、Excel 2016
答案1
這是一個解決方案:
需要建立資料夾並提供適當的存取權限。
・Windows 2008 伺服器 x64
請製作這個資料夾。
C:\Windows\SysWOW64\config\systemprofile\Desktop
・Windows 2008 伺服器 x86
請製作這個資料夾。
C:\Windows\System32\config\systemprofile\Desktop