Property to indicate if document is a template?

Hi all,

 

Is there a way to progammatically check if a document is a template (.dot or .dotm) or a document (.doc or .docx).

 

I have some code in the AutoOpen() method that I only want to fire if it is a .doc/.docx - i.e. skip the code if someone is editing a template.

 

Note: it actually needs to work in both Word 2003 and Word 2007/2010 as users can have either version.

 

Thanks

Answer
Answer
That looks pretty good for a first function. Just a couple of suggestions:

  • The variable lcName is never used after you assign it, so you might as well omit it completely.
  • If there is no period (no extension), the function will return an empty string because nothing is ever assigned to lcExt. (In VBA, strings that aren't assigned any value are automatically initialized to "".) That means that whatever procedure calls the function has to test the return value and be prepared to handle the empty-string case.
_____________________________
https://jay-freedman.info

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer
The only way to force it to be a document is to SaveAs a document format with the same name. Otherwise it remains a template :(. What that will do with the document management I have no idea, but the real problem resides with that system.

If you are testing for such a template, then test for template format with doc extension.
Graham Mayor (Microsoft Word MVP 2002-2019)
For more Word tips and downloads visit my web site
https://www.gmayor.com/Word_pages.htm

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 217 Applies to: