Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display Progress in a Userform (2000)

    Hi,

    I want to be able to display the progress of a macro in a Userform. I have a Userform which works fine buut I would like to have a field on the form which shows the User at what stage the macro is, I put text in this field and then show the form, this works fine but the macro stops, if I use the Modeless option on the display the Userform effectively disappears, well actually the frame is still there but nothing else just white space.

    Any other options

    Regards

    Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Display Progress in a Userform (2000)

    You can use Repaint to force the form to be displayed properly, for instance

    Me.Repaint

    if the code is in the module behind the user form itself, or

    UserForm1.Repaint

    (substitute the name of your form for UserForm1) if the code is in another module.

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display Progress in a Userform (2000)

    Hi Hans

    This made no difference,maybe I am putting it in the wrong place. the basic logic of the macro is this (not the code)

    Display form Userform1.Show
    ...... do some work
    Progress text = "This is the Progress Status text"
    Redisplay form Userform1.Repaint
    ...... do some more work

    The redisplay shows nothing

    If I used Userform1.Show vbModeless instead of Repaint I just get the Userform frame and white space inside.

    Any more clues.

    Regards

    Mike

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display Progress in a Userform (2000)

    Mike,

    I have a small user form with a label and an image. The form is loaded until the last macro is a series is run when it is unloaded and set to nothing.

    <pre>Sub ImportAL12()
    frmWorking.lblWorking.Caption = "Locating and Opening" & vbCrLf & "AL 1-2 Data"
    frmWorking.Repaint

    LocateAL12
    Sheets("AL1").Activate

    frmWorking.lblWorking.Caption = "Importing AL 1-2 Data"
    frmWorking.Repaint

    ....lots more code
    </pre>

    End Sub

  5. #5
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display Progress in a Userform (2000)

    Hi

    Thanks for your input, but I still cannot get it to work. I have attached a simple test which cannot get to work either, maybe you could take a look and tell me where I have gone wrong.

    Regards

    Mike
    Attached Files Attached Files

  6. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Display Progress in a Userform (2000)

    Your code need to be run when the Useform is activated. Your test program is at Userform1.show until you close the form. Then the rest of your macro runs (which does NOT display since the userform is no longer there!).

    You need to have it run from the userform_activate event or when that event calls something.

    Steve

  7. #7
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display Progress in a Userform (2000)

    A few tweaks here ... another tweak there ....
    Attached Files Attached Files

  8. #8
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Display Progress in a Userform (2000)

    I will repeat myself and then add some clarification.

    <hr>
    Your code need to be run when the Useform is activated. Your test program is at Userform1.show until you close the form. Then the rest of your macro runs (which does NOT display since the userform is no longer there!).

    You need to have it run from the userform_activate event or when that event calls something.
    <hr>

    None of the code you run, runs while the userform is displayed! After you do a userform1.show the macro "waits" at that command UNTIL the userform is CLOSED.

    You want the code to run WHEN the userform is ACTIVE not AFTER it is closed.

    To get to the events of the userform, goto VBE (alt-F11), select the userform, right-click on the form and select "view code" You want the code for the form added here!

    Check out the attached file. I do not have a progress indicator, but I have it count from 1 to 5. Your code, even with the "delay loops" was too fast to display anything. I used the timer function to delay for 2 seconds between "updates"

    Steve
    Attached Files Attached Files

  9. #9
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Long Beach, California, USA
    Posts
    233
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display Progress in a Userform (2000)

    The first example used the workbook open event... this one uses a button to trigger the form....
    Attached Files Attached Files

Posting Permissions

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