My Addin has changed Normal.dot? Huh?
When you develop a large Microsoft Word addin, you might get to a point when you get a message like "Normal.dot has changed, would you like to save?" when you try to close Word.
I'll put it straight - your addin isn't a pure soul and it is the trouble maker... :)
It can be caused by lots of lots of different things - toolbars, styles and everything that goes to the global template AKA Normal.dot.
This behavior is simple to explain - when you set something which is related to the Normal.dot, Word sets a flag that the global template has been changed and needs to be saved. This flag is the Application.NormalTemplate.Saved.
Even if you remove everything you've added before the document is closed, the flag will still indicate that a change has been made. If you don't want your users to get the irritating message of "Normal.dot has been changed, please save...", you should set this flag yourself -
In the ThisDocument_Shutdown event handler, add the following line of code:
Application.NormalTemplate.Saved = true;
|
This actually deceives Word to think that Normal.dot has already been saved, which means that the "Normal.dot has changed" pop up will not come up.
Pay attention to a few things:
- Put this line at the end of the shutdown process (just in case you touch the Normal.dot properties during this method).
- Do remove everything you've added, so you won't leave any trails.
Last thing - I've seen a strange behavior in one of my clients. Even after setting the flag to true, the "Normal.dot has changed" message still came up. Only deleting all instances of Normal.dot on the computer fixed this. I guess something has corrupted the global template... So beware of that.
Hope it helps,
Shay.