remmarg
03-22-2003, 06:43 PM
Can I make a Excel ask to close after 5 minutes. If I answer no to the message box it will automatically close if I answer yes it will start counting down another five minutes. Here is my feeble attempt. I can make it do everything but close the program instead it currently displays the message box saying "Bye Bye!!" I converted this from samples in the help file.
Module1
Sub shutdown()
'
' shutdown Macro
' Macro recorded 3/21/2003 by Jeff Grammer
'
'MsgBox "Is It OK To Close" 'Prompt,vbYesNo
Dim Msg1, Style, Title, Help, Ctxt, Response, MyString
Msg1 = "Do you want to continue ?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Question" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
GoTo 1
1 Application.OnTime Now + TimeValue("00:00:02"), "shutdown"
Else ' User chose No.
MyString = "No" ' Perform some action.
GoTo 2
2
MsgBox "Bye Bye!"
End If
End Sub
Module1
Sub shutdown()
'
' shutdown Macro
' Macro recorded 3/21/2003 by Jeff Grammer
'
'MsgBox "Is It OK To Close" 'Prompt,vbYesNo
Dim Msg1, Style, Title, Help, Ctxt, Response, MyString
Msg1 = "Do you want to continue ?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Question" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
GoTo 1
1 Application.OnTime Now + TimeValue("00:00:02"), "shutdown"
Else ' User chose No.
MyString = "No" ' Perform some action.
GoTo 2
2
MsgBox "Bye Bye!"
End If
End Sub