Document.Type property and templates

J

James

I am writing some VBA code in which I need to determine if a document is a
document (.doc) or a template (.dot). I found the Doument.Type property which
Ithought would provide the answer, but when I open a template and retrieve
the Document.Type property, it returns a value of wdTypeDocument, and not
wdTypeTemplate, as expected.

Is this not what this property represents? If not, how else can I determine
if a document is a document or template? The Document.Name property doesn't
contain the file extension.
 
G

Gordon Bentley-Mix

James,

If you truly _open_ a template (File | Open or right-click and select
"Open") then, assuming the file is actually a template (with a .dot
extension) and not a document (with a .doc extension), querying the .Type
property should return "1", which indicates that it is a template. However,
if you simply double-click on a template, this will create (under normal
circumstances) create a new document from the template, and querying the
..Type property in this instance will return "0" as expected, which indicates
that it is a document.
-----
Cheers!

Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
J

James

Hi Gordon,

I understand the difference betweening opeing a document created from a
template and opening the template itself. In this instance, I am working with
the actual template, so was surprised that the Document.Type property didn't
returm the expected value - does it depend on how the template was created
originally? For instance, if create a new document (.doc), save it, and then
sometime later rename it to *.dot, will Word recognise it as a template?
 
L

Lene Fredborg

The Type property actually tells what type of document you have.

Renaming a doc file to dot, i.e. manually changing the extension, does _not_
turn the document into a template. It will show a template icon but it is
still a document – and it will only cause confusion doing that (I have
actually seen that practiced by a solution provider). However, you can save
an existing document (.doc) as a template (.dot). To do this, select Document
Template as the type in the Save As dialog box.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
J

James

Lene,

I tested this out and you are correct: merely renaming a document to *.dot
does not make it a template. Thanks to this, I have solved my problem.

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