T
Taffy
I have the following code, if the user does not respond how do I get the
msgbox to close. After the set time is up if you press the OK or the Cancel
button the workbook is closed but because the msgbox has the focus it only
happens when the msgbox has gone.
Thanks Taffy
Dim DownTime As Date
Sub SetTime()
DownTime = Now + TimeValue("00:00:10") 'change time as needed
Application.OnTime DownTime, "SelfClosingMsgBox"
End Sub
Sub SelfClosingMsgBox()
Dim msgvar As Integer
Application.OnTime Now + TimeSerial(0, 0, 10), "ShutDown"
msgvar = MsgBox("Timer Test Closing in 10 Seconds", vbOKCancel, "Excel")
If msgvar = vbOK Then ShutDown
If msgvar = vbCancel Then Disable
End Sub
Sub ShutDown()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, Procedure:="ShutDown",
Schedule:=False
End Sub
msgbox to close. After the set time is up if you press the OK or the Cancel
button the workbook is closed but because the msgbox has the focus it only
happens when the msgbox has gone.
Thanks Taffy
Dim DownTime As Date
Sub SetTime()
DownTime = Now + TimeValue("00:00:10") 'change time as needed
Application.OnTime DownTime, "SelfClosingMsgBox"
End Sub
Sub SelfClosingMsgBox()
Dim msgvar As Integer
Application.OnTime Now + TimeSerial(0, 0, 10), "ShutDown"
msgvar = MsgBox("Timer Test Closing in 10 Seconds", vbOKCancel, "Excel")
If msgvar = vbOK Then ShutDown
If msgvar = vbCancel Then Disable
End Sub
Sub ShutDown()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, Procedure:="ShutDown",
Schedule:=False
End Sub