I haven't posted in a while, as right after my holiday in the Lake District, I started a new job and it's been a steep, but enjoyable, learning curve leaving little time for blogging.
I've been working on a personal project involving some old-fashioned Microsoft Word VBA. In this project, I needed to be able to distinguish between a Word document (*.doc) and a Word template (*.dot). Helpfully, the Microsoft Word object model exposes a Document.Type property, which returns one of the WdDocumentType values. The values of this enumeration are:
- wdTypeDocument
- wdTypeTemplate
- wdTypeFrameset
I quickly ran into an issue where one of the templates I was working with returned a value of wdTypeDocument for the Document.Type property even though the file clearly had a .dot file extension. After a bit of research, I found out that just because a document has a .dot file extension, it is not necessarily a valid template. This can happen if for example, you save a Word document, then change the file extension from .doc to .dot.
To ensure a document template has the correct Document.Type value, you need to select the "Document template (*.dot)" type in the Save As dialog box.
If you do any work at all with Word templates, it's worth bearing this little "gotcha" in mind.