Inserting a Link when a Template Opens

Inserting a Link when a Template Opens

Post by Tracy Buth » Fri, 30 Jul 2004 01:05:09


Using either Word XP or Word 2003

I have about 250 satellite sites within my company. I need
to have a way to put templates out to each site but have
the individual site logo and/or address insert into the
template automatically. I was thinking about using a macro
to insert the logo each time the template is opened. Then
updates would happen automatically (and there are a lot).
I tried having Word automatically update links in the
template but the user would have to click on yes or no to
update the link each time they opened the template and
these that would result in a HUGE amount of helpdesk
calls. I tried locking the links and tried to write a
macro to unprotect the document and then update the links
but Word isn't recording anything when I click Edit .
Links, etc.

Is there a macro that could do this or a better way of
doing this? Any help is greatly appreciated. I have about
30+ templates for each site so, yes, I am begging!!

Inserting a Link when a Template Opens

Post by Jezebe » Sat, 31 Jul 2004 12:27:59

There are several techniques you can use, depending on the details of what
you need to achieve.

1. You can write macros AutoNew and AutoOpen: these run automatically when a
document based on the template is created or opened respectively. AutoNew is
likely best for your purposes -- set the document up for the local
information when you create it, and then leave it alone (otherwise you'll
get yet more help desk calls!)

2. You can put macro code into an add-in. This is a template saved to the
Word Startup folder. Instead of putting a lot of macro code into every
template, you put the code -- once -- into the add-in, then call it from the
templates. This minimizes code your management task. In your case you might
have a "SetUpDocument" function in the add-in, called from the AutoNew macro
in each template.

3. Document properties are a convenient way to set up these sort of
customised documents. You can set these from macro code or through the File
fields. For things like local values in the address block you can have

{ DocProperty LocalAddress } etc.

You can also nest them inside other fields, so for something like an
inserted logo you can use

{ INCLUDEPICTURE {DocProperty LogoFile} }

When you set up a new document, you plug in the local values by setting the
document properties then updating fields. You can read the local values from
properties of the local, registry, and INI files, or wherever.