Modifying Recorded Macros

G

Guest

Hello,

I recorded a macro, modified it, and saved it to its own module under
Normal.dot. I added it to a toolbar and it was working fine.

Then, I went back into the VBA editor and made another modification to the
macro. I re-added it to the toolbar and now it is saying the macro can't be
found when I try to run it in a new document. When I select
Tools-Macro-Macros, the macro does not display as being available to this
document.

Since the macro is in the Normal.dot, I assumed I don't need to copy it into
every new document I open up. Since all new documents are automatically based
on Normal.dot, the macro should be automatically available to the document,
right?

So, why is Word not finding my macro?

Thanks,
Tara
 
J

Jay Freedman

Usually there are two reasons for macros to be "invisible" to the Macros
dialog (and probably to the toolbar button):

- If the Sub keyword is preceded by the Private keyword, or

- If there are parameters between the parentheses that follow the macro's
name.

If neither of these is the case, then we need to investigate some more.
 
G

Guest

Hi Jay,

Thanks for this info. Neither of these is the case. I have pasted the macro
below this message. The line I added after it was working fine is:
CommandBars("Task Pane").Visible = False

After that change, the macro could no longer be found. The other piece of
info that may be helpful is that when I open a new document, I do not get the
"Enable Macro" dialog box. Thanks,
Tara

Sub DiplayTaraToolbarOnly()
'
' DiplayTaraToolbarOnly Macro
' Closes all toolbars except Tara's
'
CommandBars("Standard").Visible = False
CommandBars("Formatting").Visible = False
CommandBars("Control Toolbox").Visible = False
CommandBars("AutoText").Visible = False
CommandBars("Database").Visible = False
CommandBars("Drawing").Visible = False
CommandBars("E-mail").Visible = False
CommandBars("Forms").Visible = False
CommandBars("Frames").Visible = False
CommandBars("Mail Merge").Visible = False
CommandBars("Outlining").Visible = False
CommandBars("Picture").Visible = False
CommandBars("Reviewing").Visible = False
CommandBars("Tables and Borders").Visible = False
CommandBars("Task Pane").Visible = False
CommandBars("Visual Basic").Visible = False
CommandBars("Web").Visible = False
CommandBars("Web Tools").Visible = False
CommandBars("Word Count").Visible = False
CommandBars("WordArt").Visible = False
CommandBars("Enterprise").Visible = False
CommandBars("Tara's toolbar").Visible = True
CommandBars("Template").Visible = False
CommandBars("Tables and Borders").Visible = False
CommandBars("Word Count").Visible = False
CommandBars("Visual Basic").Visible = False
CommandBars("Web Tools").Visible = False
End Sub
 
J

Jay Freedman

I'm not really sure what's going on. It isn't unusual for a toolbar button
to become unhitched from a macro when something about the macro changes, but
that shouldn't affect the macro's visibility in the Macros dialog.

Possibly the Normal.dot template got damaged in some way, either while you
were changing the macro or coincidentally at around that time. This is a
good reason not to put macros and toolbars into Normal.dot. Instead, put
them in an otherwise empty template, and store that in the Startup folder
listed in Tools > Options > Folder Locations. That template will be "global"
(also called an "add-in"), so it will be loaded whenever Word starts and
available in all documents just like Normal.dot. See
http://word.mvps.org/FAQs/Customization/WhatTemplatesStore.htm. Then remove
your macro and its module, and the toolbar button, from Normal.dot.

Since Normal.dot is always in the User Templates folder and global templates
are in Startup, which both "trusted" locations, you should never see the
"Enable Macro" dialog box for macros in those templates.
 

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