none
How to close Word application programmatically?

    Question

  • I need to close the document and Word application programmatically when the user pushes "Save" button, without calling document`s save dialog.

    code fragment:

            private void ThisDocument_BeforeSave(object sender, Microsoft.Office.Tools.Word.SaveEventArgs e)
            {
                object saveOption = Word.WdSaveOptions.wdDoNotSaveChanges;
                object originalFormat = Word.WdOriginalFormat.wdOriginalDocumentFormat;
                object routeDocument = false;
                this.Close(ref saveOption, ref originalFormat, ref routeDocument);                       
            }

    But in this case, save dialog is being called anyway.
    So, how can I solve this problem?
    Thursday, March 04, 2010 8:10 PM

Answers

  • Hi pahaq!

    Make sure that the e.ShowSaveAsDialog property is equal to false.
    You could also try the following:



    Globals.ThisDocument.Saved = true;

    Friday, March 05, 2010 3:17 AM

All replies

  • Hi pahaq!

    Make sure that the e.ShowSaveAsDialog property is equal to false.
    You could also try the following:



    Globals.ThisDocument.Saved = true;

    Friday, March 05, 2010 3:17 AM
  • Hi, thank you for reply.

    to solve thits problem i use - e.Cansel = true;
    Friday, March 05, 2010 2:37 PM