Microsoft KB Archive/823998

= The Close event does not fire in a Word template code extension in Visual Studio Tools for the Office System =

Article ID: 823998

Article Last Modified on 2/3/2006

-

APPLIES TO


 * Microsoft Office Word 2003
 * Microsoft Visual Studio Tools for the Microsoft Office System version 2003

-



SYMPTOMS
You can create a Microsoft Office Word 2003 template that uses a managed code extension. You can create the managed code extension by using Microsoft Visual Studio Tools for the Microsoft Office System. When you attach the Word 2003 template to another document and then you close that document, the Close event in the managed code extension does not fire.



STATUS
This behavior is a limitation of the managed code extensions for Word 2003 templates.



MORE INFORMATION
When you open the template in Word 2003 and then you close the template in Word 2003, the Close event in the managed code extension fires. However, if you attach this template to another Word 2003 document and then you close that document, the Close event does not fire.

Steps to reproduce the problem
 Start Microsoft Visual Studio .NET 2003. On the File menu, point to New, and then click Project. In the Project Types list, expand Microsoft Office System Projects, and then click Visual Basic Projects. In the Templates list, click Word Template. Name the new project WordTemplateTest, and then click OK.

The Microsoft Office Project Wizard appears. In the Microsoft Office Project Wizard, click Finish.  In the ThisDocument.vb module, replace the existing ThisDocument_Close procedure with a version that displays a message box, as follows: Private Sub ThisDocument_Close Handles ThisDocument.Close MessageBox.Show(&quot;This is the Close event.&quot;) ' Make sure that Close is not called two times. designModeClose = False End Sub </li> On the Build menu, click Build Solution.</li> On the Debug menu, click Start.

Word 2003 starts with the solution.</li> Close Word 2003.

The Close event fires.</li> Click OK to dismiss the message box.</li> Start Word 2003.

By default, a blank document is created.</li> On the Tools menu, click Templates and Add-Ins.</li> Click Attach, and then locate the WordTemplateTest.dot file.</li> Click OK to close the Templates and Add-Ins dialog box.</li> Close Word 2003.

You are prompted to save the changes to the new document.</li> Click No.

The Close event from the template does not fire.</li></ol>

Keywords: kbprb KB823998

-

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

© Microsoft Corporation. All rights reserved.