Hi,
I have obtained this VBA from the forum and have tried to changed it for my needs but whatever I do doesn't seem to work.
Can anyone out there see where I have gone wrong. When Task scheduler runs, I want it to run 3 macros if the time is before 6.30am but only run 2 after that. It will open the Excel file at 6am, but nothing seems to happen as the excel report remains open unti I arrive into work.
Code:
Private Sub TestInteractive()
Application.DisplayAlerts = False
If GetActiveWindow() = 0 Then
' We're running via the Task Scheduler: Update the Spreadsheet/Graph
If Workbooks.Count = 1 Then
If TimeValue(Now()) <= TimeValue("06:30:00") Then
Call Macro3
Call Hide
Call Mail_Sheet_Outlook_Body
ActiveWorkbook.Save
Application.Quit
Else
If GetActiveWindow() = 0 Then
' We're running via the Task Scheduler: Update the Spreadsheet/Graph
If Workbooks.Count = 1 Then
Call Hide
Call Mail_Sheet_Outlook_Body
ActiveWorkbook.Save
Application.Quit
Else
Me.Close True 'save the changes and close the workbook
Application.DisplayAlerts = True
End If
End If
End If
End If
End If
End Sub
Bookmarks