PDA

View Full Version : Solved: Assign macrot to customized button in word



Pete
09-18-2008, 12:44 AM
Hi Experts

As the title says "silly" question how do you assign VBA code to a customized button in ms word..........

Nelviticus
09-18-2008, 01:39 AM
There's probably an easier way but this is how I used to do it:

- Right-click the toolbar and click 'customise';
- On the 'Commands' tab scroll down to and select 'Macros' in the 'Categories' list;
- Make sure the right template/document is selected in the 'Save in' box;
- Drag your macro from the 'Commands' list to the toolbar.

Or to do it in code, set the OnAction property of your button.

Regards

shamsam1
09-18-2008, 02:22 AM
try this

http://www.vbaexpress.com/forum/showthread.php?t=11142

lucas
09-20-2008, 08:47 AM
I still don't understand why you would clutter up your document with buttons.

See here for an alternative (http://slucas.virtualave.net/Wink/CustomMenuItem.htm)

much cleaner and can be incorporated into your templates. Multi-level menu's are easy too.

TonyJollans
09-21-2008, 12:39 AM
I still don't understand why you would clutter up your document with buttons.

Define Clutter. :)

Working is easier if you have buttons close at hand. One reason I hate the Ribbon is the great sweep of the mouse I have to do to reach it if I am doing something towards the bottom of the screen. Personally I use the keyboard but I can easily understand somebody wanting a floating toolbar near where they're working.

lucas
09-21-2008, 08:42 AM
Well, you may have a point if we are talking a floating toolbar.....I thought the question was in regard to a button on the page which I find to be problematic in several ways.

Pete
09-22-2008, 01:38 AM
thanks for the feedback problem solved, excellent response.

fumei
09-25-2008, 01:17 PM
There was no mention of the button being in/on a page. I must admit I dislike buttons IN a document myself.

As for Nelviticus' "Or to do it in code, set the OnAction property of your button."

That ONLY applies to CommandBar buttons. There is no .OnAction for macros dragged (as a button) to a toolbar.