Microsoft KB Archive/179028

= XL97: Excel Object Is Not Closed After Running Macro =

Article ID: 179028

Article Last Modified on 10/10/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q179028





SYMPTOMS
When you close a document that contains a Microsoft Excel worksheet object, the worksheet remains open in Excel.



CAUSE
This problem occurs when the following conditions are true:


 * You open an Excel workbook object that has been inserted into a document in another program (for example, Microsoft Word). -and-


 * You run a Visual Basic for Applications macro that adds a name to the Names collection of the Excel workbook.



STATUS
Microsoft has confirmed this to be a problem in Microsoft Excel 97 for Windows. This problem was corrected in Microsoft Office 97 Service Release 2 (SR-2).

For additional information about SR-2, please see the following article in the Microsoft Knowledge Base:

151261 OFF97: How to Obtain and Install MS Office 97 SR-2



Example of the Problem
To see an example of the problem, follow these steps:

 Start Excel. Start the Visual Basic Editor (press ALT+F11). On the Insert menu, click Module.  Type the following code into the Visual Basic module sheet: Sub Test1

ActiveWorkbook.Names.Add Name:="Name1", RefersTo:="=Sheet1!a1"

End Sub  On the File menu, click "Close and Return to Microsoft Excel."</li> On the File menu, click Save As. Type Test.xls in the File Name box, and then click OK.</li> On the File menu, click Exit.</li> Start Word.</li> On the Insert menu, click Object. Click the Create From File tab in the Object dialog box. Type Test.xls, and then click OK. Click Yes if a macro virus protection warning message appears.

The Excel workbook is inserted into the Word document.</li> Right-click the embedded Excel object, point to Worksheet Object on the shortcut menu, and then click Open.</li> In Excel, Point to Macro on the Tools menu, and then click Macros. Click Test1, and then click Run.</li> On the File menu, click "Close & Return to Document1."</li></ol>

The worksheet remains open in Excel.

Additional query words: vba cannot access accessing

Keywords: kbbug kbdtacode kbprogramming kbqfe KB179028

-

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

© Microsoft Corporation. All rights reserved.