Templates property

T

Thomas F

I use the Dialogs(wdDialogToolsTemplates).Template property in some VBA code to identify which custom template (.dot file) was used to create a Word document (used for sorting files). One of our users is using our custom templates, but the Dialogs(wdDialogToolsTemplates).Template property shows that is was created using the 'Normal.dot' template in the code.

Any thoughts as to why this would be happening

Thanks!!

Thomas
 
C

Charles Kenyon

If a template can't be found by a Word document, it will reattach itself to
the normal.dot template. This can happen if servers are changed or files
moved.

Have you tried ActiveDocument.AttachedTemplate.Name or
ActiveDocument.AttachedTemplate.FullName?

These will give the name or name and path with the .dot extension. Don't
know if there is a speed differential, none that I noticed.

--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


Thomas F said:
I use the Dialogs(wdDialogToolsTemplates).Template property in some VBA
code to identify which custom template (.dot file) was used to create a Word
document (used for sorting files). One of our users is using our custom
templates, but the Dialogs(wdDialogToolsTemplates).Template property shows
that is was created using the 'Normal.dot' template in the code.
 
P

Peter Hewett

Hi Thomas

The code should work as you intend - it returns the name of the template used
to create the ActiveDocument.

I guess the things to check are:
1. Was the document actually created using Normal.dot rather than one of your
templates?
2. Is there more than one document open at the time you are executing this
code, because it'll only apply to whatever the ActiveDocument is


HTH + Cheers - Peter
 
P

Peter Hewett

Hi Charles

Yeah you're right "ActiveDocument.AttachedTemplate.Name" always gives you the
name of the attached template, irrespective of the template actually used to
create the document. However, "Dialogs(wdDialogToolsTemplates).Template"
always returns the name of the template used to create the document,
irrespective of whether it's the attached template or not. If the
ActiveDocument is actually a templae then "Dialogs
(wdDialogToolsTemplates).Template" will return a null string.

Cheers - Peter
 
C

Charles Kenyon

Thanks for the tip, Peter. I hadn't known that you could get to the original
template that way. This info may become helpful in the future for me as
several of my procedures are attaching documents to different templates upon
creation.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
T

Thomas F

Some good insight and suggestions. I will try them out, although it may take a couple of days because it is happening at an off-sight location

Thank you Charles and Peter!

Thomas
 

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