Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jul 2003
    Location
    Burnaby, Br. Columbia, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dialog box to indicate in progress action (VBA for Word 2002)

    I've got a routine that I am calling which, depending on the server's availability, can take virtually no time at all or up to 10 or 20 seconds to run. I don't want the user to worry that the process isn't happening, so I would like to indicate that the process is in progress. I don't find manipulating the status bar obvious enough to users, so I thought about displaying a dialog box while the process runs. Two problems I encountered...one, I don't want the user to close the dialog box on their own, but can't seem to figure out how to do this. For the form I am just using this code, hoping that it would just beep if they tried to close it (but of course that isn't what happens!):

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
    Beep
    End If
    End Sub

    I'm not even sure that it is possible to prevent the user from closing the dialog box, or if it is actually even desireable! But I can't think of another way to display an 'in progress' type message!

    And my second problem is that while I am showing the dialog box before calling the code, and unloading after the code runs, it doesn't seem to want to unload unless I click the 'X' on the dialog box and close it. The code I am using is:

    Userform.Show

    'Run process
    If ProcessRuns Then
    ...
    Else
    ...
    End If

    Unload UserForm

    I thought about using a Do While type statement here instead. Maybe this would work better.

    And finally, if the dialog box turns out to be the way to go, does anyone know how to animate it so the user knows it hasn't hung? Either something flashing, or a moving icon, or something like that?

    Thanks so much for your time and help!

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Dialog box to indicate in progress action (VBA for Word 2002)

    To deal with closing the UserForm use :<pre>Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
    Cancel = True
    Beep
    End If
    End Sub</pre>

    Use Unload Me rather than Unload UserForm

    Take a look at Application.OnTime, which may enable you to set up a procedure to run at a given interval to indicate something is happening.

    Andrew C

  3. #3
    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: Dialog box to indicate in progress action (VBA for Word 2002)

    Some past posts that might be useful:

    <!post=Progress Bar,289518>Progress Bar<!/post> (free control for VB6)
    Moving Objects on a VB Form (vb 6) (longish thread; using built-in controls?)
    <!post=Re: Text in Progress Bar (VB6),152959>Re: Text in Progress Bar (VB6)<!/post> (suggested sites with sample VB code)

  4. #4
    Lounger
    Join Date
    Jul 2003
    Location
    Burnaby, Br. Columbia, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dialog box to indicate in progress action (VBA for Word 2002)

    Thank you both for the excellent suggestions. I read the previous threads and they were great. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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