Question about Using a Macro from another Template

S

StevenM

I have a question about being able to use a macro which is located in another
Template.

(Chess players use text files called PGN files to store and retrieve chess
games and chess problems. You can read/understand “text file†every place I
write “PGN file.â€)

I’ve been:
(1) opening a PGN file using Word (1st Word File);
(2) opening a new Word file based on my template (2nd Word file);
(3) Cutting and pasting the PGN information from the 1st file into the 2nd;
(4) running my macro which is located in my template;
(5) the macro opens a new document based on my template (a 3rd Word file)
and transforms the PGN information in the active document (2nd Word file)
into this newly opened document (3rd Word file).

I could save time if I could open a text file in Word using my template. But
I don’t see any option for doing that. Or I could save time if I could use my
macro (which is located in my new template) from any other Word file.

The only solution which I can come up with is that I could copy my macro
from my template into the Normal template. That would cutout steps 2 & 3 (as
listed above).

Is there any other way of running a macro which is located in another
template? Or am I better off simply copying it into the Normal template?

Steven Craig Miller
New Lenox, IL (USA)
 
J

Jean-Guy Marcil

StevenM said:
I have a question about being able to use a macro which is located in another
Template.

(Chess players use text files called PGN files to store and retrieve chess
games and chess problems. You can read/understand “text file†every place I
write “PGN file.â€)

I’ve been:
(1) opening a PGN file using Word (1st Word File);
(2) opening a new Word file based on my template (2nd Word file);
(3) Cutting and pasting the PGN information from the 1st file into the 2nd;
(4) running my macro which is located in my template;
(5) the macro opens a new document based on my template (a 3rd Word file)
and transforms the PGN information in the active document (2nd Word file)
into this newly opened document (3rd Word file).

I could save time if I could open a text file in Word using my template. But
I don’t see any option for doing that. Or I could save time if I could use my
macro (which is located in my new template) from any other Word file.

The only solution which I can come up with is that I could copy my macro
from my template into the Normal template. That would cutout steps 2 & 3 (as
listed above).

Is there any other way of running a macro which is located in another
template? Or am I better off simply copying it into the Normal template?

In order to make any code available to all opened document you need to
create a global template. Luckily, it is dead easy.

Just place that third template of yours in the Word startup folder (Tools >
Options... > File Locations tab > Startup), and bingo! done; you have created
a global template. Just make sure you restart Word after having placed the
template in the startup folder if it was already running.
 
S

StevenM

To: Jean-Guy Marcil,

Thanks for your quick response. I greatly appreciate it.

Although, after I moved my template from C:\...\Microsoft\Templates
into C:\...\Microsoft\Word\Startup, I also had to change my code from:

sUsertemplates = Options.DefaultFilePath(wdUserTemplatesPath)

to:

sUsertemplates = Options.DefaultFilePath(wdStartupPath)

The only downside from making it a global template is that it no longer
appears when one does a File->New from Word. I guess I can keep two copies of
it, one in C:\...\Microsoft\Templates and the other in
C:\...\Microsoft\Word\Startup.

Anyway, thanks for the help.

Steven Craig Miller
New Lenox, IL (USA)
 
J

Jean-Guy Marcil

StevenM said:
To: Jean-Guy Marcil,

Thanks for your quick response. I greatly appreciate it.

Although, after I moved my template from C:\...\Microsoft\Templates
into C:\...\Microsoft\Word\Startup, I also had to change my code from:

sUsertemplates = Options.DefaultFilePath(wdUserTemplatesPath)

to:

sUsertemplates = Options.DefaultFilePath(wdStartupPath)

The only downside from making it a global template is that it no longer
appears when one does a File->New from Word. I guess I can keep two copies of
it, one in C:\...\Microsoft\Templates and the other in
C:\...\Microsoft\Word\Startup.

Normally, a global template is not used to create documents from, it is a
container for macros, toolbars, autotext entries, etc.

Maybe you should keep formating and macros separate. The template with the
formating/content should be u in the user template folder, the other - the
one with the macros and no formating/content - should be in the startup
folder.

This will give you more flexibility should you need to create different
layouts later. You can have as many template in the user folder but only one
with the macros.

In my opinion, this makes maintaining the whole thing easier.

Cheers.
 

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