Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

myUserForm.Show goves error 1

Status
Not open for further replies.

eman6

Programmer
Dec 7, 2004
578
CH
I have a user form in Excel 2000, I called it myUserForm.
In order to have a button on the toolbar that opens this userform, I created a one-liner as follows:

<code>
Public Sub showForm()
myUserForm.Show vbModal
End sub
</code>

I put this in the ThisWorkBook Object

I assigned the button to this macro.
When I click on the button, I get this error message:
Invalid Procedure call or argument

What am I doing wrong?


______________________________________
Do not expect the truth from a woman.
Pretending is part of her charm.
___________________________________

Eman_2005
Technical Communicator
 
Code:
Sub showForm()
    myUserForm.Show vbModal
End sub
should be placed in a standard code module, not ThisWorkbook.


Regards,
Mike
 
Tried that too. Same result. :-(


______________________________________
Do not expect the truth from a woman.
Pretending is part of her charm.
___________________________________

Eman_2005
Technical Communicator
 
That was it.
<code>
Sub showForm()
myUserForm.Show vbModal
End sub
</code>

But now it's working, after a few tries.
Originally, the form was imported from Word and modified.
At first I had it in a module like I usually do, but it gave this message
Then I read in a book from Microsoft to put the calling code (myUserForm.show) in the WorkSheet Object, so I did that, hoping it works, but it gave the same message.
Then I created a new Excel form and copied all the controls and code in it and then deleted the imported form.
By then I was still in the WorkBook Object.
Still did not work.
Then I tried back again after your suggestion, to put it in the Module.
This time it worked.
Looks like something was wrong with the imported form :-/

Thanks for the help :)

______________________________________
Do not expect the truth from a woman.
Pretending is part of her charm.
___________________________________

Eman_2005
Technical Communicator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top