XL97: Invalid Page Fault After Closing Last Open Workbook

Last reviewed: February 27, 1998
Article ID: Q158895
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

In Microsoft Excel 97, when you close the last open workbook, you may receive the following error message:

   This program has performed an illegal operation and will be shut down.
   If the problem persists, contact the program vendor.

If you click Details, you receive an error message similar to the following

   EXCEL caused an invalid page fault in module EXCEL.EXE at
   <xxxx:yyyyyyyy>.

where <xxxx:yyyyyyyy> is any of the following addresses:

   014f:300f1b0a   0137:3003cf1c
   014f:300ef16b
   014f:302946ee
   014f:3003cf1c

or any other address starting with "014f:30" or "0137:".

CAUSE

This problem may occur when the following conditions are all true:

  • You create the instance of Microsoft Excel 97 with the CreateObject method in a Visual Basic for Applications macro.

        -and-
    
  • The Visual Basic code that creates the instance of Microsoft Excel carries out the following sequence of actions before releasing control:

    1. The macro creates a new workbook, or opens an existing workbook or

          other file in the instance of Microsoft Excel.
    

    2. The macro makes the instance of Microsoft Excel 97 visible by

          setting its Visible property to True.
    

    3. The macro releases the Microsoft Excel 97 application object

          without first closing the instance.
    

WORKAROUND

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

To work around this problem, make the Microsoft Excel 97 application object visible BEFORE you create a new workbook, or open an existing workbook or other file. For example, instead of using the following code:

   xlObj.Workbooks.Open "C:\My Documents\Test.xls"
   xlObj.Visible = True

use this code:

   xlObj.Visible = True
   xlObj.Workbooks.Open "C:\My Documents\Test.xls"

When you switch the order of these two actions, the instance of Microsoft Excel 97 that you create does not stop responding when you close the last open 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.

MORE INFORMATION

In Visual Basic, you can use the CreateObject method to create new instances of applications. To create a new instance of Microsoft Excel 97, you use the following code:

   Set <objectname> = CreateObject("Excel.Application")

where <objectname> is a variable that you declare as type Object.

If you create a new instance of Microsoft Excel 97, and then leave it open for the user to close, the instance of Microsoft Excel 97 may stop responding when you close the last open workbook. This behavior occurs if the Visual Basic code opened or created any documents before making the instance of Microsoft Excel 97 visible.

   The following Visual Basic macro demonstrates the sequence of actions
   that cause the problem:

      Sub CreateMSXLObject()

          Dim xlObj As Object
          Set xlObj = CreateObject("Excel.Application")     'Action 1
          xlObj.Workbooks.Open "C:\My Documents\Test.xls"   'Action 2
          xlObj.Visible = True                              'Action 3
          Set xlObj = Nothing                               'Action 4

      End Sub


Additional query words: XL97 OLE Automation ipf gpf crash hang
Keywords : kbcode kberrmsg xlvbainfo offinterop xl97vbmigrate
Version : WINDOWS:97
Platform : WINDOWS


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: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.