+ Reply to Thread
Results 1 to 12 of 12

Run macro while userform displayed

  1. #1
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Run macro while userform displayed

    Hi all,

    I am just wondering if there is a way to allow a macro to continue running in the background once a userform has been displayed? I have disapled the 'close' button and the last action of the macro is to re-enable it.

    Thanks muchly

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run macro while userform displayed

    Yes, you can show the userform modelessly by specifying False as the argument to the Show method. For example:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Re: Run macro while userform displayed

    Sorry Romper, I dont understand where or how I would use that at all?

    Below is the code I currently use, the idea being 'InformationBox' is shown to let the user know that something is actually happening, and then the macro runs on it's jolly way until the end, at which point the button for the user to close the form is activated. I'm sure you are probably with me, but not sure how to use your example in conjunction with the below?

    Please Login or Register  to view this content.
    Thanks again.
    Last edited by duckboy1981; 07-07-2009 at 11:10 AM.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run macro while userform displayed

    Change:
    Please Login or Register  to view this content.
    to:
    Please Login or Register  to view this content.
    basically.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Run macro while userform displayed

    duckboy,

    Please edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Re: Run macro while userform displayed

    Just tried that but it throws up an error - Run-time error '401' - 'Can't show non-model form when a model form is displayed'

    I'm assuming that is because I have another form up infront of that one? Is there anyway around it at all without setting the other form to False?

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run macro while userform displayed

    Couple of options:
    1. Hide the other form
    2. Show your second form modally and have it actually run the rest of your code when it activates, rather than having the code in run from the calling routine.

  8. #8
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Re: Run macro while userform displayed

    Ok, I'll have a play then and figure out the best way of doing it.

    Thanks muchly.

  9. #9
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Re: Run macro while userform displayed

    Sorry to be annoying...

    One last query - now that the form is modeless, it will not allow me to close it using the button on the form and this code -

    Please Login or Register  to view this content.
    Is that because it is modeless and is and inherint part of running a modeless form or is there some other factor causing it? This button was allowing me to close the form before hand, and then the code would run.

    Thanks again.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run macro while userform displayed

    That code should be fine. Are you sure your other code is not still running?

  11. #11
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Re: Run macro while userform displayed

    There is another form running behind it, if that would cause it to not work, but the macro is totally finished. I have changed it to InformationBox.Hide now and that works, so I will stick with that!

    Thanks for the help.

  12. #12
    Registered User
    Join Date
    06-21-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Run macro while userform displayed

    Hi there,

    I have a similar problem.

    When the form is displayed, I want that a code which verifies if the return button is pressed runs continuously.
    I have a login form and after fill the name and password fields, the user hit return and the go button is pressed too.


    Any suggestions?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1