Results 1 to 13 of 13

Thread: User Message

  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    User Message

    Ok, here comes a full-on admission of my total ignorance of how the heck a VBA programmer puts up a user message while something goes on in the background. Gee, wiz, my brain is busted. I've resorted to the status bar and title bars. But no user EVER looks at those.

    I need a non-modal box that pops up center screen during the time eater in the background then goes away when the user can proceed.

    What do you all use?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: User Message

    There was a thread some time back with ideas on this.

    One way is to display a userform; you can have it take up the entire application window if necessary. The userform doesn't go away until processing is completed.

    And you can entertain the users with colorful status updates, slides, home movies or careening radio show hosts on the userform while they are waiting.

  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: User Message

    I think this might be new in Office2000, because in the old days you had to go to the Windows API for progress bars and such. Kevin, does this work for you?

    UserForm1.Show vbModeless

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: User Message

    Hi Jeff,

    If Kevin doesn't want the user to mess around in Word until the procedure has stopped running, shouldn't the form be shown modal anyway? <img src=/S/crazy.gif border=0 width=15 height=15>

  5. #5
    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: User Message

    If it's modal, VBA stops and waits for the user to dismiss it, so the only hope is modeless.

    However, I tried it with a modeless box, and the content of the simple userform (just a "please wait" label) didn't show (title bar shows, and a blank white body). Finally got it:

    WaitBox.Show vbModeless
    WaitBox.Repaint
    ...
    WaitBox.Hide

    Nice. :-)

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Message

    I get all warm and fuzzy calling Windows API functions. See my recent post updating my discovery on elapsed time.

    So, by all means, feel free post API code.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Message

    Jeff,

    Ok, Ok, looks nice to me too. Show me your waitbox already! (Can you tell I'm eager to see this work?)
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: User Message

    Kevin, Jeff:

    The modal form is still IMO the better way to go, precisely because it does prevent the user from working in the application while the code is running.

    The key to getting the code to run and have the modal form showing too, is to show the form before the main processing code runs.

    For example, suppose you have a utility that takes about a minute to run, and that the user triggers by pressing a toolbar button. The only code that would be behind that button would be along the lines of:

    frmStatus.Show

    frmStatus, in its initial appearance, can look like a typical message box with a prompt something like "Processing will take up to one minute, OK to continue?"

    On OK, your code resizes the userform, hides the initial message label, shows the "Please wait" label, repaints the form.
    And then under that you have the calls to the procedure or procedures that actually do the processing:

    lblStatus.Text = "Now reformatting your hard drive"
    Call ReformatHardDrive

    lblStatus.Text = "Now performing some useless function"
    Call PerformUselessFunction

    The whole time this is running, the userform owns the application window so the user has no option but to wait til it's finished.
    And this is where you can use the userform to run slide shows, display banner ads, whatever.

    Call TheFinalSubProcedure
    Unload Me

    Playing around with this can be a lot of fun.....

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Message

    Gary,

    I agree with the modal aspect in my case. The user needs to wait till the underlying code finishes. But I don't want the user to have to click anything in the message window.

    The user must do nothing -- not even click an Ok button -- while the Please wait.. message is on the screen. It's got to work like this:

    1. User clicks a check box which invokes code to populate a specific array which gets assigned to a combobox.

    2. As soon as the check box is clicked, the Please wait... message appears. When the combobox is populated, the Please wait message (in a form or whatever) goes away and the dropdown is displayed.

    I can see your point about prompting the user in the case of a long duration -- they may want to opt out or continue, but in my case, I need a informational message to keep them in their seats while VBA prepares the list.

    BTW, I figured out why the mousepointer change was not working. I'll post the finding in that thread. So, I might just be content with the hourglass as my Please wait message. Still, I've got to get a handle on this technique.

    Thanks for helping.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  10. #10
    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: User Message

    Oh, I get it: put the code into the form module. Hmmm... I think I'll wait for a case where there is a longer delay before implementing that.

  11. #11
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Message

    In case it's of interest, I spotted something in another thread (posted br Cri, I believe) which led me to <A target="_blank" HREF=http://www.rb-ad.dircon.co.uk/rob/excelvba/tips/index.htm>this page</A> - just in case you wanted to add a progress bar. Look for 'VBA Status Bar Guage' link.

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Message

    Leif,

    Thanks for you input. The only problem I have with using (read that: "depending on") the status bar is the users rarely look at it. I'll check out the link though. Maybe helpful anyway.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: User Message

    Jeff,

    I guess I misunderstood. I thought you were asking does calling APIs work for me.

    You meant does

    Userform1.show vbModeless

    work for me. Sorry about that.

    I'm using Word 97, and no that don't work.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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