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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Change to Normal.dot warning - only on Vista 1

Status
Not open for further replies.

seaport

MIS
Jan 5, 2000
923
US
I am using Access 2003 to create a VBA function that generates a word 2003 document based on an existing word document. (In other words, I use a template, which is a doc file). It works fine on XP machine, but on a Vista machine, I always got the warning "Changes were made that affect the global template normal.dot" after I closed the generated document. As far as I know, that normal.dot file cannot be overwritten. So Word gives me a couple warnings that I have to click No to dismiss. It is really annoying.

Regarding my VBA code, there is nothing fancy. It writes text into a table, makes some text bold, changes the header, and that's it. As I said before, it worked fine in XP.

I checked out the link below but does not help.

Any suggestions?
 
As far as I know, that normal.dot file cannot be overwritten. "

Huh? Any normal.dot file can be (and often IS, which is why you ahould not use it!) overwritten.

"In other words, I use a template, which is a doc file."

Huh? Templates are not .doc files. They are .DOT files.

It sounds like you are using normal.dot to act as a document template. While common, this is not a good idea.

Why you are only getting this in Vista, I do not know. I do not use Vista. However, it certainly does sounds like you are making changes to normal.dot itself - again, not a good idea.

Gerry
 
I think I did not describe the problem clearly.

"In other words, I use a template, which is a doc file."
What I meant was the code below.

dim doc as Word.Document
set doc=wdApp.Documents.Add("A_Word_File.doc")

I considered "A_Word_File.doc" as a template, which could be a doc file or dot file. Anyway, I did NOT use "normal.dot" anywhere in my code.

"As far as I know, that normal.dot file cannot be overwritten. "
This may be true. But in my situation, Vista thought that I changed the normal.dot and asked me to save it. (I did not have the option not to save it.) When I did, I got the warning message that normal.dot could not be overwritten. That's why I had to go through several clicks to dismiss Vista's warnings.

Bottom line, I do not know how my code changed normal.dot since normal.dot was not in code at all.

 
There are two different issues.

First your question about changes to normal.dot. Your Normal Template is where Word stores some information about you (the user) and the environment. Exactly what it stores is sometimes difficult to pin down. You may, or may not want such changes saved, which is why Word (subject to a user setting) asks the question. The most likely cause of 'unexplained' changes is an AddIn, and behaviour may differ from machine to machine for no obvious reason.

When driving Word from code you can choose to explicitly save, or discard, the changes and the question will then not be asked. To discard the changes, simply tell Word that it has already been saved:
Code:
[blue]NormalTemplate.Saved = True[/blue]

The second issue - that of what is, or isn't a template - is more subtle. One big difference between creating a new document based on a Word Template (normally the 'correct' way) and basing a new document on an existing document is that, in the latter case, macros in the document get copied to the new one. One other difference worthy of note is that the new document is based on a Template (all Word Documents are) and one created from a Template is 'attached to' that Template, whereas one copied from another document has the same attachment as the original document. In most cases, including yours, it would seem, there is probably no significant difference in behaviour.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Thanks. Tony.

Your code does the trick.

NormalTemplate.Saved = True

I noticed, before Word 2003, the difference between creating a new document based on a Word Template (normally the 'correct' way) and basing a new document on an existing document is that the existing document file is locked if the new document built upon it is open, but a Word template will not be locked in the same situation.

This problem no longer exists for Word 2003, which is good.

 
Bottom line, I do not know how my code changed normal.dot since normal.dot was not in code at all."

Bottom line is: if your code changed anything, and the template attached to A_Word_File.doc is Normal.dot, then normal.dot IS "in code". Thus, if anything is changed, then normal.dot is changed.

Tony's NormalTemplate.Saved = True works because it tells Word that Normal.dot is saved, regardless of any changes that may have happened. Therefore, in essense, those changes are lost...which, apparently, what you want.

"I considered "A_Word_File.doc" as a template, which could be a doc file or dot file. "

You may consider it so, but if it is .DOC, then it is simply is not a template. A template is a .DOT. You may indeed be using it like a template, but it is not actually one.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top