我在调用Workbooks.Open()
时出现错误异常:
使用“ 1”作为参数的“打开”:“旧格式或无效的类型库。 (来自HRESULT的异常:0x80028018(TYPE_E_INVDATAREAD))“
$Files = Get-ChildItem -Path "C:\daily reports" "*.xlsx" -Recurse |
Select -Expand FullName
$excl = New-Object -ComObject "Excel.Application"
foreach ($file in $Files) {
$wrkb = $excl.Workbooks.Open($file)
$excl.DisplayAlerts = $false
$wrkb.Save()
$wrkb.Close()
}
$excl.Quit()
kill -processname excel