I can't quit word application safely.. RRS feed

  • Question

  • Hi, 

    Im writing a program that modifies word document and then save it with saveAs and closes the document. Everything works fine, but after the code line of quitting word application it always prompts a window with a message that the template is used by another user , and after i press OK it opens dialog which says that the template need to be saved (under another name,  not Normal.dotm..)

    What does it mean?. 

    Wednesday, January 30, 2013 9:09 PM


  • Hi hurrem

    I'm going to assume that you don't want to save any changes back to Normal.dotm...

    Before you try to quit Word, put in a command to tell Word it does not need to worry about saving changes to the default template:
      WordApplication.NormalTemplate.Saved = true

    This command can be anywhere in your code, but it does, of course, need to follow whatever action is prompting Word to think the default template is "dirty".

    The message you're seeing is an indication that either someone else is using the same Normal.dotm template, that another instance of WinWord.exe is running that has a file-lock on the template (check the Processes) or that Word has crashed on this machine in such a way as to make Windows think a file-lock is in effect for Normal.dotm.

    As far as your program goes, as long as you don't need to save anything to Normal.dotm (such as a macro), you don't need to worry about the cause. The Saved command should make the problem irrelevant to you. But please note that, if the user has made any changes he wants to save, these would be lost if he has not saved them manually. So you're walking a fine line, here...

    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, January 31, 2013 7:36 AM