WD2000: DocClose/FileClose Macros Fail to Work As Expected

ID: Q220505


The information in this article applies to:
  • Microsoft Word 2000


SYMPTOMS

When you create or convert a macro that uses one of the following Word built-in command names for the macro name

FileClose
DocClose
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:

  1. Open your document or template.


  2. On the Tools menu, point to Macro, and then click Visual Basic Editor.


  3. On the View menu in Visual Basic Editor, click Project Explorer.


  4. 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:
    Project(MyDoc)


  5. In the Project Explorer window, double-click Microsoft Word Objects to view ThisDocument.


  6. In the Project Explorer window, double-click ThisDocument.


  7. In the ThisDocument code window, click to drop down the list of Objects, and then click to select Document.


  8. In the Procedures list box, click to select Close.


  9. 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 


  10. On the File menu, click Save <your document name>.


  11. On the File menu, click Close and Return to Microsoft Word.



STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

For 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.

Additional query words: vba

Keywords : kbdta wd2000
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: June 15, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.