Consulting

Results 1 to 13 of 13

Thread: Can only run a User Form once..?

  1. #1
    VBAX Regular
    Joined
    Jul 2020
    Posts
    11
    Location

    Can only run a User Form once..?

    I picked up a document from a colleague the other day. After running one of the user forms in the document the macro button is then greyed out, and the user form can only be accessed and run through the VBA editor.

    Anyone know why I'm getting this behaviour?

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    Something written in the macro code ?

  3. #3
    VBAX Regular
    Joined
    Jul 2020
    Posts
    11
    Location
    Not that I can see.

    Is this a common issue?

  4. #4
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    No, it is not common.

    Post your code / workbook.

  5. #5
    VBAX Regular
    Joined
    Jul 2020
    Posts
    11
    Location
    In fact, upon thought, the ‘Interactive Userform examples’ word doc from Greg Maxey’s site does the same thing – only when you populate the first user form. Well it does for me anyways.

    https://gregmaxey.com/word_tip_pages...userforms.html


    As you can probably tell, I’m still new to this.

  6. #6
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    Using the macro code from the linked resource you provided in your last post,
    BOTH UserForm commandbuttons include this line in the macro :

     Me.Hide
    When you click the button on either form, it hides the userform. Making it appear
    as though the form can only be used once.

  7. #7
    VBAX Regular
    Joined
    Jul 2020
    Posts
    11
    Location
    Commenting out the Me.Hide did not change this behaviour.

  8. #8
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    I don't have an answer. My experience lies with VBA in Excel not Word.

    As an experiment, I created a third UserForm using the same CommandButton code as the other two userforms. This new form
    disappeared as well after clicking the button.

    I reviewed all of the code in all Userforms and Modules in the example download file provided in the resource link you posted.
    I cannot find any other references to closing or hiding the userform in the code.

    I am at a loss to explain.

  9. #9
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    I created a new Word document with a User Form. This example ... the Form remains visible.

    Either the example you provided is corrupted or there is an unknown attribute causing the UserForm to auto-close.
    Attached Files Attached Files

  10. #10
    VBAX Regular
    Joined
    Jul 2020
    Posts
    11
    Location
    Thanks for your time...

  11. #11
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    I am sorry I couldn't have been more helpful. I wish you well in your search for an answer.

    Best wishes !

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Quote Originally Posted by ReltubP View Post
    Anyone know why I'm getting this behaviour?
    Not without seeing the document

    Clean any sensitive information, and post it
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  13. #13
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    118
    Location
    How are you starting or calling your form?
    Do you have a MyUserForm.Show command?

    Your actual code and document/template would help.

Posting Permissions

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