0

我正在使用 Windows 任务调度程序在发生 excel 崩溃(应用程序事件 1000)时运行以下脚本文件。如果我手动运行脚本,则 Excel 文件“E:\Test.xlsm”将作为例外打开。但是,当从任务管理器调用时(在 excel 应用程序崩溃的情况下)excel 不会打开。至少,当我稍后检查时,没有打开 excel 的实例。从事件查看器窗口我可以看到我的 vbs 文件确实被调用了,但由于某种原因它没有打开 excel。

什么可能导致我手动运行脚本(双击它)和从 Windows 任务管理器调用它时的不同行为?

我正在使用 Windows 2008R2 和 excel 2010(32 位)。

谢谢!

Option Explicit

ExcelRestart

Sub ExcelRestart()    
  Dim xlApp 
  Dim xlBook 
  Set xlApp = CreateObject("Excel.Application") 
  xlApp.DisplayAlerts = False  
  Set xlBook = xlApp.Workbooks.Open("E:\Test.xlsm")
  xlApp.visible = True 
  xlBook.activate
  Set xlBook = Nothing
  Set xlApp = Nothing
End sub
4

0 回答 0