autoexec macro

  • Thread starter Clayton L. Wilson
  • Start date
C

Clayton L. Wilson

I have a template in which a lot of documents use. Is there any way I can
have a macro run every time I open a document created with this template?
 
J

Jezebel

Keep looking, it's there. Word supports these auto macros:

Macro name When it runs
AutoExec When you start Word or load a global template
AutoNew Each time you create a new document
AutoOpen Each time you open an existing document
AutoClose Each time you close a document
AutoExit When you quit Word or unload a global template







Clayton L. Wilson said:
AutoOpen what? I looked in help, but I haven't found anything.
 
C

Charles Kenyon

Name your macro AutoOpen rather than AutoExec. An AutoExec macro is for a
global template rather than a document template. It runs once when the
template is loaded. An AutoOpen macro runs whenever the template or a
document based on the template is opened.
--

Charles Kenyon

See 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.

Clayton L. Wilson said:
AutoOpen what? I looked in help, but I haven't found anything.
 
M

Malcolm Smith

Clayton

If you find the template within the IDE (Alt-F11) then double-click on
'This Document' in the project tree to the left.

Then look at the editor pane and you will see two drop down boxes; the
fist one contains the list of all the objects, in this case it will be
'Document' and the other one the events associated with that object.

Make sure that 'Document' is selected in the left hand one and then look
for 'Open' in the right hand one.

The IDE ought to create a sub looking something like:

Private sub Document_Open()


End Sub

And that is where you place your code.

Hope that this helps.
Malc
www.dragondrop.com
 
W

Word Heretic

G'day "Clayton L. Wilson" <[email protected]>,

The uh, help system, is different in the VBE. Open that up with an
Alt+F11 and type in "auto macro" into the index search.


Clayton L. Wilson said:
I have a template in which a lot of documents use. Is there any way I can
have a macro run every time I open a document created with this template?

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 

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