Microsoft KB Archive/220505

= WD2000: DocClose/FileClose Macros Fail to Work As Expected =

Article ID: 220505

Article Last Modified on 5/13/2002

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



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

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:

 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:

Project(MyDoc)

 In the Project Explorer window, double-click Microsoft Word Objects to view ThisDocument. In the Project Explorer window, double-click ThisDocument.</li> In the ThisDocument code window, click to drop down the list of Objects, and then click to select Document.</li> In the Procedures list box, click to select Close.</li>  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 </li> On the File menu, click Save  .</li> On the File menu, click Close and Return to Microsoft Word.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

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: kbbug kbpending KB220505

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.