Recording new macro - default module

Z

zsplash

I have several modules in my Normal.dot. When I use the macro recorder, and
indicate to save the macro in the Normal.dot, a new module "NewMacros" is
inserted, and the macro code is inserted there. Is there any way to make
the default module for new macros be one of the other modules I have already
inserted?

TIA
 
M

Mark Tangard

zsplash,

Don't we wish. No, there's not. This is especially irksome
when manually customizing menusm because "Normal.NewMacros"
takes up so much of the width of the box from which you drag
the item!
 
Z

zsplash

Thanks for the answer, Mark. Now, sort of a corollary to that: Is it
possible for me to have a Something.dot to store code which can be readily
accessed for many users, but if individual users want to write their own
macros that they be saved in their own Normal.dot? Then, they'd either
point to my Something.dot or their own Normal.dot, if the macro/sub names
were unique? (Hope that's clear.)

st.
 
M

Mark Tangard

Hi st,

Yes, it's not only possible, it's preferable. Always leave
Normal.dot for the user to play scratchpad with, rather than
altering, replacing, or otherwise meddling with it from an
administrative perch. The Something.dot template is called
a "global" or "add-in," and you'd want to place a copy in
each user's Startup folder (location varies but is given
at Tools­> Options­> File Locations-> Startup), and use a
login/startup sequence that updates it, if needed, at bootup.
For lots more info on how to set this all up properly, see:
http://www.mvps.org/word/FAQs/MacrosVBA/DistributeMacros.htm

And yes, as long as macro names are unique, the user need not
do anything special to execute macros in either template --
all non-argument-taking macros in both the user's Normal and
your add-in will appear in the Tools­> Macros­> Macro dialog
(unless you've made any of them Private Subs), so there would
be no conscious "pointing" involved except for one perhaps
unlikely case: If a macro in one template has the same name
as a macro in the other, the listings in the Macro dialog
for those 2 macros will include the module name and sometimes
also the project name, e.g., Normal.NewMacros.StartMyCar.
But appropriate naming of the shared macros can help avoid
that. (Also, if you're ready to use add-ins, you're also
nearly ready to build custom menus & toolbars, meaning the
Macro dialog may soon be just a quaint piece of history for
your organization.)

(In light of my earlier comment, you can probably guess how
succinct my first add-in's project and module names were.
Two characters each, if I remember right....)

To keep the integrity of your add-in, you'd only want users
*creating* macros in their Normal.dots, not in the add-in.
This, of course, is the default; and the steps required to
edit an installed add-in are comfortably beyond the ken of
most non-programmers anyway. Also, any updates you make
to the add-in -- which may be frequent at first if your
users (or you) start enjoying it and suggesting refinements
or new gadgetry -- will replace the users' local copies, so
in the rare event where a user had indeed mangled his/her
copy of the add-in, the mutant template could be quickly
replaced with your master copy. More on this at the link
above.

We'll expect to see you graduate out of the beginners group
soon. ;)
 
J

Jay Freedman

Hi, z,

There's no way to change the default, but you *can* affect which module the
recorder will drop its code into.

In the Record Macro dialog, in the Macro Name box where VBA suggests
"Macro1", type in the module name, a dot, and the macro name. Also set the
Store Macro In box to the template or document you want to use. For example,
if you enter

SaveMacros.SaveTwoCopies

then the recorded code will make a macro named SaveTwoCopies in the module
SaveMacros (which will be created if it doesn't already exist).
 
Z

zsplash

Thank you for that info, Jay. Another reason for naming modules
succinctly.....

st.
 

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