Consulting

Results 1 to 4 of 4

Thread: Using a button to open a userform trouble

  1. #1
    VBAX Newbie
    Joined
    Feb 2013
    Posts
    2
    Location

    Using a button to open a userform trouble

    I'm trying to get a button in a word document to bring up a userform. Whenever I click the button I get the message variable not defined. Here is my code:
    Private Sub CommandButton1_Click()
    userform1.Show
    End Sub
    Any ideas

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Yes. The userform is not named userform1. Or....the userform is not available - perhaps it is not in the project.

    Or...the procedure is not in a module that can find userform1.

  3. #3
    VBAX Newbie
    Joined
    Feb 2013
    Posts
    2
    Location
    I checked, it is indeed called userform1, it is in the same project and should be available. the exact same code worked in excel. I retyped it and recreated the userform to avoid any issue with copying across different programs. My roommate had the same problem, figured it out but refuses to tell me. All he said was it was something stupid.

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    "but refuses to tell me."

    Really. While it is likely true that it is simple, pass this on to him..."You are a juvenile idiot. Grow up if you can."

    It is something simple. It usually is. What module do you have the Sub in; or maybe try getting rid of Private.

    So you are saying you recreated things (module, userform) and you CAN get .Show to work; then work backwards.

Posting Permissions

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