Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can close the active document or you can specify a document to close.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. For more information, see Features available by Office application and project type.
There are two procedures for closing the active document: one for document-level customizations and one for VSTO Add-ins.
Call the Close method of the ThisDocument
class in your project to close the document associated with the customization. To use the following code example, run it from the ThisDocument
class.
Note
This example passes the wdDoNotSaveChanges value to the SaveChanges parameter to close without saving changes or prompting the user.
Call the Close method of the ActiveDocument property to close the active document. To use the following code example, run it from the ThisAddIn
class in your project.
Note
This example passes the wdDoNotSaveChanges value to the SaveChanges parameter to close without saving changes or prompting the user.
The way that you close a document that you specify by name is the same for VSTO Add-ins and document-level customizations.
Specify the document name as an argument to the Documents collection, and then call the Close method. The following code example assumes that a document named NewDocument is open in Word.
Note
This example passes the wdDoNotSaveChanges value to the SaveChanges parameter to close without saving changes or prompting the user.
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!