WD2000: DocClose/FileClose Macros Fail to Work As Expected (220505)
The information in this article applies to:
This article was previously published under Q220505 For a Microsoft Word 2002 version of this article, see 274008.
SYMPTOMS
When you create or convert a macro that uses one of the following Word built-in command names for the macro name
the macro fails to run as expected when you close a document using the Close button in the upper right corner of the document window.
WORKAROUND
To work around this problem, you can use the Visual Basic for Applications Document Close event.
To create a Document Close event procedure, do the following: - Open your document or template.
- On the Tools menu, point to Macro, and then click Visual Basic Editor.
- On the View menu in Visual Basic Editor, click Project Explorer.
- In the Project Explorer window, double-click your document or template project to view Microsoft Word Objects.
For example, if your document name is MyDoc, in the Project Explorer window, double-click:
- In the Project Explorer window, double-click Microsoft Word Objects to view ThisDocument.
- In the Project Explorer window, double-click ThisDocument.
- In the ThisDocument code window, click to drop down the list of Objects, and then click to select Document.
- In the Procedures list box, click to select Close.
- In the code window, type your Visual Basic for Applications commands between the Private Sub Document_Close and End Sub command lines.
For example:
Private Sub Document_Close
' < Type your commands here >
End Sub
- On the File menu, click Save <your document name>.
- On the File menu, click Close and Return to Microsoft Word.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. MORE INFORMATIONFor more information about the Document Close event, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Close event in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 5/13/2002 |
---|
Keywords: | kbbug KB220505 |
---|
|