Reatin Macros in document from template

R

Richard

Hi
I have created a template with some complex macros.

Naturally when the template is opened, it opens as a separate WORD document
& allows the macros to be run.

However, once the document has been saved & closed, the macros cannot be
re-run.

Is there a way to retain the macros in the new document, so the macros can
be run another time please?
 
G

Graham Mayor

Instead of opening a document from the open template, open a new document
from the template. File > New or in Word 2007 Office Button > New.

As long as the template is available to the document the macros it contains
will be available. What you appear to be doing is creating a new document,
presumably based on the normal template which doesn't have your macros.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Richard

Hi Graham

Thanks for that.

Your answer sounds fine for those who are 'in the know' and/or have the
template on their own hard drive.

I am a member of a large organisation with the templates kept in a central
location & could not see how the average ignorant Joe would be able to open
in the way you suggest.

However, I have done some digging & most templates here are available from a
button placed in a toolbar backed with code to offer a selection & open with
the line of code below:

WordBasic.FileNew Template:=Location

Where location is the path & filename.

So, you did put me on the right track, 'cos that works.

Many thanks
 
G

Graham Mayor

The normal intended and correct use of a document template has always been
to create new documents from it.

If templates are in a shared location then you can use the Workgroup folder
function to make the templates more widely available. Though with Word 2007
you can make just about any location a trusted location.

It should not be necessary to use WordBasic commands to create new
documents. Use instead the vba command

Documents.Add "d:\path\template.dot"

Whether the macros will then run will depend on your security settings.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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