XL97: Unable to Close File Activated by WorkbookBeforeClose

Last reviewed: March 13, 1998
Article ID: Q172749
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you attempt to close a workbook, the pointer becomes an hourglass, and the workbook remains open. After you attempt to close the workbook, any cell entries that you make in the workbook do not appear. However, these cell entries appear in another workbook.

CAUSE

This problem may occur if all of the following conditions are true:

  • You attach a Visual Basic for Applications macro to the WorkbookBeforeClose event.

        -and-
    
  • You set the Cancel argument of the WorkbookBeforeClose event to True.

        -and-
    
  • You switch to another workbook in the macro that is attached to the WorkbookBeforeClose event.

You cannot close the workbook that is activated by the macro that is attached to the WorkbookBeforeClose event in another workbook.

WORKAROUND

To work around this problem, save the workbook with a different file name. To save the workbook with a different name, follow these steps:

  1. Switch to the workbook that contains the macro that is attached to the WorkbookBeforeClose event.

  2. Switch to the workbook that you cannot close.

  3. On the File menu, click Save As.

  4. Type a new name for the workbook in the File Name box.

  5. Click Save.

NOTE: To close the workbook that contains the macro that is attached to the WorkbookBeforeClose event, set Cancel to True and remove the line of code that activates the other workbook.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

For more information about the WorkbookBeforeClose event, click the Office Assistant while in the Visual Basic Editor, type "workbookbeforeclose," click Search, and then click to view "WorkbookBeforeClose Event."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176476
   TITLE     : OFF: Office Assistant Not Answering Visual Basic Questions


Additional query words: XL97
Keywords : kbprg xlvbainfo
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.