Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA: MsgBox and Timeout (Word 2003 VBA)

    I have a simple AutoOpen macro as follows:
    _______________________

    Sub AutoOpen()

    ' When a Word file is opened, macro indicates whether Track
    ' changes is on or off

    On Error Resume Next
    If ActiveDocument.TrackRevisions = True Then
    MsgBox "Track Changes is On"
    ElseIf ActiveDocument.TrackRevisions = False Then
    MsgBox "Track Changes is Off"
    End If

    ' Macro indicates whether file contains any tracked revisions

    If ActiveDocument.Revisions.Count > 0 Then
    MsgBox "Document contains tracked revisions"
    ElseIf ActiveDocument.Revisions.Count = 0 Then
    MsgBox "Document contains NO tracked revisions"
    End If

    ' Macro sets view to Final Showing Markup

    With ActiveWindow.View
    .ShowRevisionsAndComments = True
    .RevisionsView = wdRevisionsViewFinal
    End With
    Exit Sub

    End Sub
    _______________________

    I'm getting tired of having to click OK (amazing what little annoyances become big annoyances over time <img src=/S/smile.gif border=0 alt=smile width=15 height=15> ) and would like the macro to act as if I clicked OK in the MsgBox after about 3 seconds. I have tried various things, such as adding .Show Timeout:=3000, none of which work. I can't find in VBA documentation anything that seems to work with MsgBox. Does anyone have a simple-to-implement suggestion?

    Thanks.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VBA: MsgBox and Timeout (Word 2003 VBA)

    MsgBox does not have that feature. You can display a built-in dialog for a certain number of (milli)seconds, but that doesn't really help you in this case. You could write the information to the Status Bar, but that might be quickly replaced by something else, so perhaps it isn't durable enough. You could write to a custom Toolbar, but would that be annoying, too? Perhaps there is no neat way of avoiding a UserForm (assuming a UserForm can be displayed only for a specified period of time). [I don't have MS Office on this new laptop yet, so I can't check.]

  4. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: VBA: MsgBox and Timeout (Word 2003 VBA)

    As Jefferson more or less suggests, you'll have to create a userform; you can use Application.OnTime in the Initialize event of this form to call a macro that'll close the form after some seconds.

  5. #4
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA: MsgBox and Timeout (Word 2003 VBA)

    Thanks for the replies, Jeffrerson and Hans. I was afraid that would be my only option. For the time being, I'll continue clicking.

  6. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: VBA: MsgBox and Timeout (Word 2003 VBA)

    Here is some sample code for you...

    In Module1
    <code>Sub AutoOpen()
    UserForm1.Show vbModeless
    End Sub

    Sub HideForm()
    UserForm1.Hide
    Unload UserForm1
    End Sub
    </code>
    In UserForm1
    <code>
    Private Sub btnOK_Click()
    Project.Module1.HideForm
    End Sub

    Private Sub UserForm_Activate()
    Application.OnTime When:=Now + TimeValue("00:00:05"), Name:="Project.Module1.HideForm"
    End Sub
    </code>
    You also need to have labels on UserForm1 that display the message you want (using code in UserForm_Activate) and an OK button so you can close the form before the time has elapsed if you want.

    StuartR

  7. #6
    2 Star Lounger
    Join Date
    Sep 2005
    Location
    Poughkeepsie, New York, USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA: MsgBox and Timeout (Word 2003 VBA)

    Thanks, Stuart. I may give it a try.

  8. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA: MsgBox and Timeout (Word 2003 VBA)

    Note thet Word's OnTime Method only can remember ONE set event. If you schedule two ontime events in Word, only the last one is retained, the first one is overwritten.

    Excel just piles them on top of each other and executes them in order.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •