Moving location of document's attached template

S

Stephen English

In our organisation we load a global template. This has a lot of code and
User Forms in it.

We also have 1000's of documents on our intranet based on a template which
users download to review and update which uses code in the document template.
All documents are in this path C:\Program Files\Microsoft
Office\Templates\COS - General
For operational reasons (moving to AD from Novell), we need to now load
these templates into C:\Documents and Settings\senglish\Application
Data\Microsoft\Templates\COS - General
This means that a toolbar button specific to that template, is not available
nor is any code. We can overcome it by giving them a button on the menu bar
on the global template (called Check Template) but it would be nice to do it
more automatically.

Is there anywhere I can put code in the global template that runs every time
a document is opened please?
....or any other suggestions to address this problem.
Thanks
Stephen
 
J

Julie

Hello Stephen,

There are a number of choices for resolving that problem: Here's one of a
number of ways:

The easiest way if feasible for your environment is to install the new
template into to the ROOT, of either, the paths set for User Templates or
Workgroup Templates under Tools - options - location of files. That way,
the documents should automatically attach to the new template of the same
name provided that the old template doesn't exist. I assume that is not an
option according to your message. The automatic re-attachment only works
for templates located in the ROOT of one of those folders, not sub-folders.

Alternatively, create a document opening event procedure in a global
template to identify documents still showing as attached to the old template
and when found, re-attach the document to the new template.

You can identify documents attached to the old template by reading the
settings on the tools & addins dialog.

Your document opening event procedure might look like this pseudo-code

If document opened is type template
If
LCase(Application.Dialogs(wdDialogToolsTemplates).Template) =
LCase("x:\oldtemplatepath.dot") Then
activedocument.AttachedTemplate = new template path
End If
End If

Hopefully this gives you some ideas.

It works. I have a scheme along these lines but with many, many more
variables at play running for a several thousand users since 2001 and it has
been a livesaver. I have one additional component to my "scheme" - that
is, users's don't touch normal.dot and attached templates don't contain
auto-open macros. Therefore I am free to use a normal.dot Auto-open macro
to make sure the document opening event procedure in the global template has
been instantiated (and not lost as a result of run-time error earlier in the
Word session) so I can be sure it RUNS!. That is a safety net only not
critical to your problem because if your event procedure doesn't get
instantiated then the users will know right away because the toolbars won't
work as is the case now.

Regards,
Julie

PS. If you go to the Word MVP site, you should be able to find a support
document re creating document opening event procedures. If not, please post
back and I'll find you a link to follow.
 
S

Stephen English

Hi Julie
Thank you for you informative and detailed reply. That all makes sense and
I have used similar code to attach a different template before. However,
what interests me is "create a document opening event procedure in a global
template". I have the global template but what do I call the procedure in
the global template to make it run every time a document is opened please?
Thanks
Stephen
 

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