I am developing a workbook that manages menubars and toolbars so I can easily add macros to shortcut menus, delete buttons on tool bars etc.
As part of this spreadhseet, i would like to be able to easily assign a particular icon to a button on a toolbar. I have created a temporary toolbar that has 100 buttons with random faces. The buttons are not associated with an OnAction event (yet). What I want to be able to do, is click a button and capture which button was clicked. Once I know which button was clicked, I will know which button to assign to the main toolbar I am working with.
I had 2 ideas, neither which I know how to get to work.
1. Assign every button 1 - 100 to the same macro, and try to capture the name or number of the button that was just clicked. I am not aware of an event that will allow me to do this however.
2. Build a custom macro at the time that I add the button to the toolbar. ie if I add button 24, I call it button24, then create a macro called button24Click() that passes number 24 back to my other code. Trouble is I don't know how to get VBA to create VBA code.
If anyone can help with how to do either of these, or has any other ideas, I would love to hear from you.
Matt
Bookmarks