Home > Net >  Assign a macro to userform command button onclick
Assign a macro to userform command button onclick

Time:03-25

I have a userform with one button and I have some macros written in a module1.

I want that when button is clicked the macros run. I am trying this in word using VBA

Any suggestions?

CodePudding user response:

Is there a reason to not put your procedure in the UserForm itself? Is it needed outside the userform?

If not, it should be in the UserForm's code as the click handler for that button.

If it is used outside the UserForm, you could put the following in your click event handler in the form:

Application.Run "module1.mymacro"

or

Call module1.mymacro

or even simply

mymacro

Where the name of the macro you plan on running is named "mymacro."

For more, see:

  • Related