Close Method
Collapse the table of content
Expand the table of content

DocumentBase.Close Method (Object, Object, Object)


Closes the document.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public void Close(
	ref object saveChanges,
	ref object originalFormat,
	ref object routeDocument


Type: System.Object

Specifies the save action for the document. Can be one of the following T:Microsoft.Office.Interop.Word.WdSaveOptions values: F:Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges, F:Microsoft.Office.Interop.Word.WdSaveOptions.wdPromptToSaveChanges, or F:Microsoft.Office.Interop.Word.WdSaveOptions.wdSaveChanges.

Type: System.Object

Specifies the save format for the document. Can be one of the following T:Microsoft.Office.Interop.Word.WdOriginalFormat values: F:Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat, F:Microsoft.Office.Interop.Word.WdOriginalFormat.wdPromptUser, or F:Microsoft.Office.Interop.Word.WdOriginalFormat.wdWordDocument.

Type: System.Object

true to route the document to the next recipient. If the document does not have a routing slip attached, this argument is ignored.

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the Close method to close the document and prompt the user to save changes as a Word (.doc) file. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentClose()
    object saveChanges = Word.WdSaveOptions.wdPromptToSaveChanges;
    object originalFormat = Word.WdOriginalFormat.wdWordDocument;
    object routeDocument = true;

    this.Close(ref saveChanges, ref originalFormat, ref routeDocument);
Return to top
© 2016 Microsoft