Programatically creating a toolbar to run macros

P

philipsj

Hey all,

I need to come up with a way to programatically create a toolbar that
contains some of my macros that will be used by various computers. Am
i correct in assuming that if i manually create a toolbar that it wont
show up on another computer? Under this assumption, i was trying to
add some code into my autoload section that will automatically create a
toolbar with three menus, about 5 items in each, name each macro (ie.
open, save, exit, load, etc) and then assign each item to its
respective macro.

The way i begun this process was to record a macro of myself doing
this. It worked to an extent and by that i mean it created the
toolbar, but none of the text i entered showed up and none of the
macros were assigned. I was wondering if anyone knew of an easy way to
do this or should i continue trying to figure this out.


Thanks,

Justin
 
C

Chip Pearson

If you manually create a tool bar, you can Attach that toolbar to
a workbook. This can be done only manually -- there is no
programmatic way to attach a toolbar. In Excel, go to the View
menu, choose Toolbars, then Customize. In that dialog, click
Attach and select your toolbar in the "Custom toolbars" list and
Copy it over to "Toolbars in workbook".

Then, when you send the workbook, it will contain the toolbar and
be accessible in the sent workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
P

philipsj

alright sweet...i had done that already i just wasnt sure if that was
gonna work....i will have to wait till monday to check it on another
computer. Thanks!
 
A

AESanto

Try this:

For add a menu

Sub menu()
CommandBars("Worksheet menu bar") _
..Controls("Edit").Controls.Add(Type:=msoControlPopup).Caption = "My menu"
..Controls("Edit")..Controls("My menu").OnAction = "My Macro"
End Sub

This will add a MyMenu menu in Edit menu that runs My macro 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