Close Method
Home Page (Objects) | Overview | FAQ | Reference
Applies to: Document object, TextDocument object, TextWindow object, Window object
Closes windows.
Syntax
object**.Close(** [SaveChanges] )
Parameters
object
An expression that evaluates to one of the objects in the Applies To list above.
SaveChanges
(Optional) An enum of type DsSaveChanges that indicates whether to save changes to a document before closing it. Following are the possible values, which have the Long type:
dsSaveChangesYes Saves all changes and does not prompt the user (the default).
dsSaveChangesNo Does not save changes, and does not prompt the user.
dsSaveChangesPrompt Prompts the user to save changes. If the user chooses not to save the changes, Close returns the enum dsSaveStatus with the value dsSaveCanceled; otherwise Close returns dsSaveSucceeded.
Return Values
The Close method returns the enum dsSaveStatus, which has one of the following values:
dsSaveCanceled Indicates that the user chose not to save changes to the document.
dsSaveSucceeded Indicates that the user saved changes to the document.
Remarks
The following table summarizes the results of using Close with objects in the Applies To list:
Object | Results |
Document TextDocument |
Closes all windows associated with the document and removes them from the Windows collection obtained by using the Windows property of the Application object.
Closes the document and removes it from the Documents collection. |
TextWindow Window |
Closes the window and removes it from the Windows collection obtained by using the Windows property of the Application object. Additionally, if that window was the only one open on a document, then that document is closed and removed from the Documents collection |
Example
The following example saves all changes to the current document and then closes all windows in the document:
ActiveDocument.Close