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

attachedtemplate function behaviour?

Status
Not open for further replies.

tomdeblauwe

Programmer
Sep 2, 2002
1
BE
Hello,

I'm using vba to change the template of a document. The document is based on the template 'versiontemplate.dot'. This template contains a macro which contains code to change the template to 'comparetemplate.dot'. I call this macro from a .vbs file. It compares the document and the saves it to a temporary location, with 'comparetemplate.dot' as the new template. The problem is that the following line:

Code:
ActiveDocument.AttachedTemplate = sTempCompare + "\comparetemplate.dot"

...pops up a yes-no-cancel dialog which asks if I want to save the modifications, but I don't understand this: I'm not closing the document! AND I saved the document just before calling the above line. I tried to use the autoclose macro to put a 'activedocument.save' statement in because I thought maybe word closes the document and reopens it with the new template, but that didn't help, still got the dialog. Also putting the save statement in thisdocument's close event didn't help. I also used 'application.displayalerts=wdalertsnone' but still got the dialog.

What I know is that once the attachedtemplate line is called, the rest of the sub isn't executed anymore apparently. However this is logical of course, but it's not logical that I get a dialog that asks me to save the changes as if the document is getting closed, because I only attached another template... If I change the template manually then I don't get a save dialog. Also if I put only the attachedtemplate line in a macro, then run the macro from within the toolsmenu, I don't get asked to save the document. I really don't understand it. I'm also sure that I get the save dialog from calling that one line.

I use Windows 2000 professional and Office 2000

Thanx for any help
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top