Windows Task Scheduler vbs file fails (but runs fine manually)

773 views Asked by At

I'm using windows task scheduler to run the below script file on the event of an excel crash (application event 1000). If I run the script manually, the excel file 'E:\Test.xlsm' opens as excepted. However, when called from the task manager (on the event of an excel application crash) excel doesn't open. At least, there is no instance of excel open when i later check. From the event viewer window i can see that my vbs file is indeed called, but for some reason it isn't opening excel.

What can possibly be causing the different behavior between my running the script manually (double clicking on it) and when it is called from the windows task manager?

I'm using windows 2008R2 and excel 2010 (32-bit).

Thanks!

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
0

There are 0 answers