PDA

View Full Version : Templates(1).saved not giving me the desired result!!!



Kamikaze
08-22-2007, 04:03 AM
Hi all,

I have wrote a small addin that performs a few actions, it will sit in the STARTUP folder of various machines.

The first thing the template does is check if a particular dll exists

If fsoWS.FileExists("c:\program files\ws\ws.dll") Then

depending on this result it will then programatically add this library for use with the rest of the functionality.

Templates(1).VBProject.References.AddFromFile ("C:\Program Files\ws\ws.dll")

This obviously changes the state of Templates(1).saved to false so i then change it back to true.

Templates(1).Saved = True

The problem is that it still prompts to save the template and that is something that can not happen in my situation.

I did read this article that mentions that if you use an embedded object or activex control resetting the flag does not always reset its "dirty" state.

http://support.microsoft.com/kb/325620

This applies to office xp though and i am using office 2003.

Has anyone experienced something like this, anyone have any suggestions at all as i have tried absolutely everything i can think of.

Many thanks
Tim

fumei
08-22-2007, 07:40 AM
A Reference is not an embedded object. You are modifying the file. You can say it is saved (.Saved = True), but Word is smart enough to figure out that it is NOT saved.

Why not just save it?

Kamikaze
08-22-2007, 07:53 AM
Hi Fumei,

I'd rather not save it as the file is rolled out to hundreds of machines via a login script, some of which have the dll and some which dont, the main reason i'd like to avoid this is because the script will want to copy over the file everytime it has changed, this would be a quite large unnecessary
overhead.

That aside, i have actually managed to rectify the problem, there must have been a realtime setting or something causing a change in the template as when i done it all again from scratch it worked perfectly.

Thanks anyway though :)