Hi,
I have a macro timer that runs every set period. This macro works just fine, but at some point, a user might need to stop the macro timer from running its next cycle.
The period can be as short as every 5 seconds or as long as 24 hours.
I've tried several of the error(18) capture methods, but it leaves the macro in break mode preventing the original macro from being executed / restarted again without manual intervention.
It looks like I can also run a second macro when the sub macro_timer() is running. The goal is to stop the loop when the person presses the execute button on the kill macro.
current timer code:
Thanks for the help,
Mike
I have a macro timer that runs every set period. This macro works just fine, but at some point, a user might need to stop the macro timer from running its next cycle.
The period can be as short as every 5 seconds or as long as 24 hours.
I've tried several of the error(18) capture methods, but it leaves the macro in break mode preventing the original macro from being executed / restarted again without manual intervention.
It looks like I can also run a second macro when the sub macro_timer() is running. The goal is to stop the loop when the person presses the execute button on the kill macro.
current timer code:
Code:
Sub macro_timer()
On Error GoTo error_msg
refresh_hours = ThisWorkbook.Sheets("Control Panel").refresh_hours_textbox.Value
refresh_minutes = ThisWorkbook.Sheets("Control Panel").refresh_minutes_textbox.Value
refresh_seconds = ThisWorkbook.Sheets("Control Panel").refresh_seconds_textbox.Value
interval_time = refresh_hours & ":" & refresh_minutes & ":" & refresh_seconds
'Tells Excel when to next run the macro.
Application.OnTime Now + TimeValue(interval_time), "thisworkbook.pdf_print_macro"
GoTo continue_macro
error_msg:
MsgBox "An error has occured while setting the timer interval." & Chr(10) & Chr(10) & "Restart the PDF Print maacro to continue." & Chr(10) & Chr(10) & "If the problem continues, contact your Macro Support Team.", vbCritical + vbOKOnly, "CRITICAL ERROR WHILE RUNNING THE TIMER"
End
continue_macro:
End Sub
Thanks for the help,
Mike