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

Re: Moving location of document's attached template by Julie

Julie
Mon Jan 21 01:27:41 PST 2008

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.


"Stephen English" <StephenEnglish@discussions.microsoft.com> wrote in
message news:29A343E7-BC2F-4D38-8FF2-C8895229AD17@microsoft.com...
> 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
>



Re: Moving location of document's attached template by StephenEnglish

StephenEnglish
Tue Jan 22 16:08:02 PST 2008

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


"Julie" wrote:

> 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.
>
>
> "Stephen English" <StephenEnglish@discussions.microsoft.com> wrote in
> message news:29A343E7-BC2F-4D38-8FF2-C8895229AD17@microsoft.com...
> > 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
> >
>
>
>

Re: Moving location of document's attached template by Julie

Julie
Wed Jan 23 00:34:51 PST 2008

Hi Stephen

Here's a link from the Word MVP site:

http://word.mvps.org/faqs/macrosvba/AppClassEvents.htm

I haven't read that doc before but from a quick scan it appears to cover
what you require.

There may also be a support doc in Microsoft KB as well.

Good luck!
Regards,
Julie

"Stephen English" <StephenEnglish@discussions.microsoft.com> wrote in
message news:95328CDA-AF19-4902-B138-8DA32DDC8F9C@microsoft.com...
> 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
>
>
> "Julie" wrote:
>
>> 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.
>>
>>
>> "Stephen English" <StephenEnglish@discussions.microsoft.com> wrote in
>> message news:29A343E7-BC2F-4D38-8FF2-C8895229AD17@microsoft.com...
>> > 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
>> >
>>
>>
>>
>