Global Macro (dot) not running

M

Michael Tissington

I have created a new template and then put it into the STARTUP folder.
I look at the Tools/Templates dialog and I see that my dot is loaded.
The dot has been signed.

My dot has AutoOpen and AutoNew subs defined but neither of them are
invoked.

What do I need to do to have these subs run when a user opens a new
template?

Thanks.
 
J

Jay Freedman

Hi, Michael,

There are two distinct types of templates, distinguished by where they're
stored. See
http://www.mvps.org/word/FAQs/Customization/WhatTemplatesStore.htm.

Templates in the User Templates or Workgroup Templates folders (as set in
the Tools > Options > File Locations dialog) are meant for basing new
documents. They appear in the File > New dialog. These are the only
templates whose AutoNew and AutoOpen macros will run.

Templates in the Startup folder are loaded when Word starts, and are
independent of any particular document (that's why they're called "global"
templates). Their non-Auto macros and toolbars are available in all
documents.

The Normal.dot template is a hybrid -- it lives in the User Templates folder
and is used to base new documents that aren't based on another template, but
it's also global.

An AutoNew or AutoOpen macro in Normal.dot or another document-base template
can call a macro in a global template, if you want to avoid duplicating code
into multiple templates. This makes maintenance easier, since any change has
to be made only once.
 
M

Michael Tissington

Jay,

My template basically adds a command to the insert menu.

How can I do this with a global template?

Thanks.
 
A

Andy Newland

You could add this code to the AutoExec event in your
globval template. This code will run evrytime the word
document is opened.

Andy
 
C

Charles Kenyon

AutoOpen and AutoNew macros don't run in a global template being used as a
global template. It sounds as if you may want an AutoExec macro. Note though
that often the best way to make a global menu change in a global template is
to simply change the menu in the global template itself (manually or using
code) and save the change. The change will be reflected in the user's menus
when the template is loaded as an add-in.
--
See <URL: http://addbalance.com/word/movetotemplate.htm> for step-by-step
instructions on moving / sharing / copying customizations including
AutoText, AutoCorrect, keyboard assignments, macros, etc.


--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
O

OughtFour

Michael said:
Jay,

My template basically adds a command to the insert menu.

How can I do this with a global template?

You could do this without using VBA by

(1) Opening your add-in
(2) Adding the command to the command menu while the customization context
is the add-in (use Tools>Customize...)
(3) Saving the add-in
(4) Making sure it is in the startup folder the next time you start up.

That's what I would do--and have done--to make global menu customizations
without changing Normal.
 

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