Renamed module, now toolbar buttons don't work.

B

Bruno G.

Hello!

While cleaning up my Normal.dot, I renamed most of the VBA code modules.
Now toolbar buttons that are running macros no longer work. I can't find a
way to change the macro name associated with the button. Is there anyway to
do this? I don't want to delete all my macro buttons and recreated them
from the start...

Thanks in advance!

Bruno G.
 
M

Malcolm Smith

Bruno

Why are is your 'good' code in Normal.dot ?? If you have useful code
that you want to keep it's advisable (as in "it's advisable not to swim
the English Channel after a long and heavy lunch with bricks in your
pockets and your left arm tied to your right ankle") to put the code into
a template which lives in the start-up folder.

Since you are going to have to move the modules to somewhere safer you may
as well do this now and then worry about the buttons later. At least
your code will be safe.

- Malc
www.dragondrop.com
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Malcolm Smith > écrivait :
In this message, < Malcolm Smith > wrote:

|| Bruno
||
|| Why are is your 'good' code in Normal.dot ?? If you have useful code
|| that you want to keep it's advisable (as in "it's advisable not to swim
|| the English Channel after a long and heavy lunch with bricks in your
|| pockets and your left arm tied to your right ankle")

ROTFLMAO

I was merely smiling until I got to the "tied to" business! Then I was in
the floor... just picturing it!
Good one!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
C

Chad DeMeyer

Bruno,

First, do as Malc suggests. Normal.dot is too vulnerable to be safely used
as a code repository.

When you have done that, you can change the buttons' OnAction property.
Suppose you have a button, the first button on a custom toolbar you have
named "My Macros".

CommandBars("My Macros").Controls(1).OnAction = 'the macro's name

Look up OnAction in Word VBA help.

Regards,
Chad
 
B

Bruno G.

Thanks for the tip... never thought about that!

One thing though, the code, when placed in the STARTUP folder, is not
accessible to edit... I tend to modify this code quite often to add & tweak
stuff. Is there a way to make it editable? Or maybe I could keep my code
in Normal.dot and export the VBA modules for backup whenever I make
changes...

Bruno
 
C

Chad DeMeyer

Just create a macro that opens your template and add a button to your
toolbars for one-click access to edit your add-in. You could even add a
line to that macro that automatically opens the Visual Basic Editor.

Regards,
Chad
 
B

Bruno G.

Doh!

I never realised that I could just open the template... Must've tried it
sometime and something went wrong...

I was closing Word, removing the template from STARTUP, openning the
template, making the changes, closing Word, returning the template to the
STARTUP folder and restarting Word...

No wonder I found that cumbersome!

Well, thank you all for saving my code AND my sanity!! :)

Bruno
 
B

Bruno G.

Doh! (again...)

I was trying to use OnAction but it returned an empty string. Problem was
that I was trying to modify a menu item, so I was missing a 'level' in my
code... Finally got around to change my macro name!

Thanks anyway for your help.

By the way, here's my command now:
CommandBars("Menu Bar").Controls(11).CommandBar.Controls(1).OnAction = "the
macro's name"

Bruno
 

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