How can I list documents' templates

S

Steve Franks

I have to look at a large number of templates, with a view
to updating them and making them consistent.
I've discovered a couple that are based on non-standard
templates. i.e. The Tools | Templates Addins dialog shows
a filename.

When I try to list the documents attached templates every
document has Normal.dot attached.
If I try to list their Addins, there aren't any.

Does anyone have any clue how I can find the templates
using vba?
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Steve Franks > écrivait :
In this message, < Steve Franks > wrote:

|| I have to look at a large number of templates, with a view
|| to updating them and making them consistent.
|| I've discovered a couple that are based on non-standard
|| templates. i.e. The Tools | Templates Addins dialog shows
|| a filename.

This means that they are not templates. A template cannot have an attached
template.

|| When I try to list the documents attached templates every
|| document has Normal.dot attached.
|| If I try to list their Addins, there aren't any.
||
|| Does anyone have any clue how I can find the templates
|| using vba?

If you want to know if it is a document or a template, try:

MsgBox ActiveDocument.Type

0 = Document
1 = Template

Or, use the following code to test if the currently active document is a
document, and if so, to display its attached template name:

'_______________________________________
With ActiveDocument
If .Type = wdTypeDocument Then
MsgBox .AttachedTemplate
End If
End With
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Steve Franks

Thank you Jean - Guy, you are right they are actually documents, rather than
Word templates.
For my purposes they are templates in the literal sense of the word i.e.
recipes for users to follow.

The problem appears to be that some of the documents have attached templates
that don't exist, or at least I don't have access to them. These are exactly
the ones I want to investigate, but Word substitutes Normal.dot as its
response to ActiveDocument.AttachedTemplate.
I can see them when I look for them, but programmatically how do I obtain
their names?
Thanks again,
Regards
Steve
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Steve Franks > écrivait :
In this message, < Steve Franks > wrote:

|| Thank you Jean - Guy, you are right they are actually documents, rather
than
|| Word templates.
|| For my purposes they are templates in the literal sense of the word i.e.
|| recipes for users to follow.
||
|| The problem appears to be that some of the documents have attached
templates
|| that don't exist, or at least I don't have access to them. These are
exactly
|| the ones I want to investigate, but Word substitutes Normal.dot as its
|| response to ActiveDocument.AttachedTemplate.
|| I can see them when I look for them, but programmatically how do I obtain
|| their names?

Of course, as soon as you open the document if Word does not find the
template, it attaches Normal.dot.

If you want to know what the template is before opening it, you have to use
the Template built-in document property.
E.g:
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate)

You have to read that property before opening the document.
See
http://support.microsoft.com/?scid=kb;en-us;Q224351
and
http://word.mvps.org/faqs/macrosvba/DSOFile.htm

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Graham Mayor

Why don't you use them as true templates by saving them as such?

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jean-Guy Marcil

Bonjour,

Sorry, I do not know where I was this morning, but I was not thinking
straight... See my comments in-line!

Dans son message, < Jean-Guy Marcil > écrivait :
In this message, < Jean-Guy Marcil > wrote:

|| Bonjour,
||
|| Dans son message, < Steve Franks > écrivait :
|| In this message, < Steve Franks > wrote:
||
|||| Thank you Jean - Guy, you are right they are actually documents, rather
than
|||| Word templates.
|||| For my purposes they are templates in the literal sense of the word
i.e.
|||| recipes for users to follow.
||||
|||| The problem appears to be that some of the documents have attached
templates
|||| that don't exist, or at least I don't have access to them. These are
exactly
|||| the ones I want to investigate, but Word substitutes Normal.dot as its
|||| response to ActiveDocument.AttachedTemplate.
|||| I can see them when I look for them, but programmatically how do I
obtain
|||| their names?
||
|| Of course, as soon as you open the document if Word does not find the
|| template, it attaches Normal.dot.

True, but the document still knows it "real" Template, as long as you do not
change the attached template in the Templates & Add-in dialog.

||
|| If you want to know what the template is before opening it, you have to
use
|| the Template built-in document property.
|| E.g:
|| MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate)

If you test for the attached template, you will get Normal.dot, as you have
found out. But you can still use
MsgBox ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate)
after opening the document and the original template name will be displayed.

||
|| You have to read that property before opening the document.
|| See
|| http://support.microsoft.com/?scid=kb;en-us;Q224351
|| and
|| http://word.mvps.org/faqs/macrosvba/DSOFile.htm

These links may be of interest to you (for future reference), but are not
necessary in this case.

Sorry again.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

Steve Franks

Thanks gentlemen.
It isn't my call. I would set them up as global templates, if I could.
I'll try to find out why they are currently held as documents.
Once again, many thanks.
 

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