When executing the below code, vbscript doesn't appear to wait for the Excel OnTime method to complete and just closes Excel. Is this expected behavior? If so, how to get around it? I know the positive branch works.
Code:Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open(fName, 0, False) 'True = read only If TimeValue(Now()) > TimeValue("09:55:00") Then xlApp.Run "MyMacro" Else xlApp.OnTime TimeValue("10:00:00"), "MyMacro" End If xlBook.Close True xlApp.Quit





Reply With Quote