Assign Sub to Custom Button

A

Aggie94

How can I assign a particular Sub to a button that I create
programmatically? In other words, I have created a subroutine that will
create a custom toolbar and buttons on the user's computer. It will created
(if it does not exist) or be made visible when a particular workbook is
opened and hidden when the workbook closes. How do I assign other
subroutines to those custom buttons through the programming? None of the
buttons will be for existing Excel functions.
 
F

Frank Kabel

Hi
the easiest thing would be:
- delete the old button (enclosed in 'on error resume next / on error
goto 0' statements to prevent error if it does not exist)
- rebuild the menu and add your new function/sub to it
 
A

Aggie94

I tried the OnAction property but it runs the associated sub at the time the
toolbar is built. After that it does nothing.

I am printing out the topic you provided but I have not had a chance to look
through it. I'm sure the answer is there but I may be back.

Thanks for the help.
 
T

Tom Ogilvy

You asked:
How do I assign other
subroutines to those custom buttons through the programming?

In that vein, I would create the toolbar each time the workbook was opened
or if it is in an addin, each time excel was opened and the addin loaded.
Then you should know it is always pointing to the correct file to run the
macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top