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

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Dialog box to indicate in progress action (VBA for Word 2002)

    Author
    Topic
    #405727

    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!

    Viewing 3 reply threads
    Author
    Replies
    • #835944

      To deal with closing the UserForm use :

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

      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

    • #835945

      To deal with closing the UserForm use :

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

      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

    • #835968

      Some past posts that might be useful:

      Progress Bar (free control for VB6)
      Moving Objects on a VB Form (vb 6) (longish thread; using built-in controls?)
      Re: Text in Progress Bar (VB6) (suggested sites with sample VB code)

      • #836708

        Thank you both for the excellent suggestions. I read the previous threads and they were great. smile

    • #835969

      Some past posts that might be useful:

      Progress Bar (free control for VB6)
      Moving Objects on a VB Form (vb 6) (longish thread; using built-in controls?)
      Re: Text in Progress Bar (VB6) (suggested sites with sample VB code)

    Viewing 3 reply threads
    Reply To: Dialog box to indicate in progress action (VBA for Word 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: