How do I auto-load macros stored in a Template

J

jtanaka

I'm storing several macros in a Word 2003 .dot file for maintainability
reasons.

In test.dot:

Sub CreateMenu()
....
End Sub

I have a document with this template attached and I want it to run one of
the macros from the template when this document is opened.

Private Sub Document_Open()
Call CreateMenu
End Sub

When I attempt to run this macro, I get the Compile Error: "Sub or Function
not defined"

How can I make sure that the macros stored in a template used by the word
document that I am opening will be loaded when Document_Open() is run?
 
C

Cindy M.

Hi =?Utf-8?B?anRhbmFrYQ==?=,

It's not clear from your problem description whether CreateMenu and
Document_Open are in the same template? ("I have a document with this template
attached...")

If they're not in the same template, then you need to use Application.Run to
execute a macro in another project.
I'm storing several macros in a Word 2003 .dot file for maintainability
reasons.

In test.dot:

Sub CreateMenu()
....
End Sub

I have a document with this template attached and I want it to run one of
the macros from the template when this document is opened.

Private Sub Document_Open()
Call CreateMenu
End Sub

When I attempt to run this macro, I get the Compile Error: "Sub or Function
not defined"

How can I make sure that the macros stored in a template used by the word
document that I am opening will be loaded when Document_Open() is run?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

jtanaka

Thank you Application.Run was what I was missing
(and yes, these sub's are in different files).
 

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