【发布时间】:2020-05-19 06:54:29
【问题描述】:
我有一个脚本可以检查文件夹中的 excel 文件,然后如果此“阈值”大于 0,则运行来自另一个 excel 文件的宏,该宏与这些 excel 文件夹交互。
当我通过 powershell ISE 手动运行该进程时,它工作正常,但是当我使用 windows 任务调度程序时,powershell 脚本运行但调用的 excel 宏不运行。有什么建议为什么会出现这种情况?此进程以前在 windows 2008 服务器上运行良好,但被迁移到 windows server 2012 并且无法正常运行
if ($count -gt $threshold){
$excel = new-object -comobject excel.application
$workbook = $excel.workbooks.open("D:\TimesheetService\IS-FS - AutoTimesheetLoader v2.3 - UAT.xlsm")
$worksheet = $workbook.worksheets.item(1)
$excel.Run("ImportTime")
$workbook.close($false)
$excel.quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel)
Remove-Variable excel
}
【问题讨论】:
-
看看superuser.com/questions/579900/…。 BTW:你为什么使用
MacOS-Tag?
标签: excel vba powershell windows-server-2012