Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store variable in word document? 1

Status
Not open for further replies.

hstijnen

Programmer
Nov 13, 2002
172
NL
Hi,

I've the following problem: I've a word template and a set of documents based on that template. When the template is updated (same name and location), the documents are connected with the the new template, but are based on the elder version of the template. I would like to recognise that situation.

My question is: is it possible to store a variable or something like that in a document that corresponds with a version number in the template, in order to check the version?

Thanks for ideas,

Henk
 
Hi Henk,

Certainly possible. You can use Document Variables or Properties and put code in the Document_Open event of the Template to check the Document being opened against the Template, and do as you will.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
You certainly could use a variable and do checking. However, if you put the following into the template Document_Open event, any document created from the template will, on being opened, update the styles and save the document. That is, any changes to the template styles will automatically updated.
Code:
With ActiveDocument
 .UpdateStylesOnOpen = True
 .Save
End With

If, on the other hand, you are talking about content in the template - that is a completely different question. But since you have not specified this....

Gerry
 
Thanks for the suggestion, Gerry.
I'll do it with variables, for I want to handle docs from inside and outside my company different. An outside doc will be based on Normal.dot, and I want to discriminate it from an intern doc on Normal.dot.
 
Then you are using templates incorrectly. Your documents should NEVER be based on Normal.dot.

Gerry
 
Your documents should NEVER be based on Normal.dot.

Why not?

Any new document not based on some other template is by default based on Normal.dot.
 
Precisely. Properly, all documents should be based on a specific template, not normal.dot.

The reason being, normal.dot is the file used by Word itself. It gets heavy I/O - reads and writes. Microsoft itself recommends using proper templates - that is, user/organization created templates for documents. Normal.dot gets corrupted easily - even Microsoft says that. For THAT reason, deleting normal.dot is one of the first things troubleshooters of Word suggest.

And, in fact, deleting normal.dot IS one of the things that can often fix problems. Because it DOES get corrupted.

Therefore, basing documents on normal.dot - even though most people do so - is not the best thing.

I never make documents from normal.dot. My normal.dot is tiny, tight and clean. All autotext entries, all autocorrect entries, all styles, all macro code, all of it is in other .dot files. Entries, or code, that I commonly use are in a .dot file that is loaded globally, so these are always available - just like they would be in normal.dot.

These .dot files are, of course, backed up.....

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top