View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default MsgBox; if 10-seconds, assumed 'No' Clicked

Hi,

You can do this

BtnCode = CreateObject("WScript.Shell").Popup("Your Text", 5, "Title", 4 + 32)
MsgBox BtnCode

This produces a popup message box that times out after 5 seconds. You can
then test which button was pressed to decide what to do next

-1 No button pressed
6= yes
7 =No

Have a look here for more info on this method and what the numbers at the
end do

http://msdn.microsoft.com/en-us/libr...9f(VS.85).aspx
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"ryguy7272" wrote:

Sub ShutDown()
MsgBox "If there is no Activity in 5 seconds, Excel will save your work
and close. Do you need more time?", vbYesNo
On Error Resume Next
If vbYes Then
Call SetTime
Exit Sub
Else
DownTime = Now + TimeValue("00:00:05")
Application.OnTime DownTime, "ShutDown"
Call GonnaSave
End If
On Error GoTo 0
End Sub

I'm testing out some auto-close code. I'm wondering if the MsgBox actually
needs a user to click 'No' for the 'Else' part of the macro to fire. I think
so... How can I tell excel to go ahead and run the 'Else' if 'Yes' is NOT
clicked in 10-seconds?

As always, thanks!

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.