Microsoft KB Archive/231129

= XL2000: Invalid Page Fault When Using Macro to Close Workbook =

Article ID: 231129

Article Last Modified on 9/25/2003

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q231129



SYMPTOMS
When you click a control from the Forms toolbar (such as a Button) to run a Microsoft Visual Basic for Applications macro, and that macro uses the Close method, you may receive the following error message:

This program has performed an illegal operation and will be shut down.

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

Excel caused an invalid page fault in module Excel.exe at 015f:300e7e53.



CAUSE
This problem occurs when the following conditions are true:
 * Your workbook contains both ActiveX controls and controls created from the Forms toolbar.

-and-
 * You first click an ActiveX control.

-and-
 * Without selecting anything else, you then click a Forms control.

-and-
 * The Forms control runs a macro that closes the workbook.



WORKAROUND
To close the active workbook without receiving the error message, use either of the following methods.

Method 1: Use an ActiveX Control Instead of a Forms Control
Instead of running your macro with a control from the Forms toolbar, consider using an ActiveX control instead. For example, if you currently use a Button control from the Forms toolbar, use a CommandButton control (which is an ActiveX control) from the Control Toolbox instead.

To attach your current code to the Click event of the ActiveX control, double-click the command button. In the CommandButton1_Click event procedure, copy your code from the Forms button.

Method 2: Select a Cell
Select a cell on the worksheet before you click the Forms control that runs your macro. This removes the focus from the ActiveX control, allowing the workbook to close properly. You can either select a cell using your mouse or use a macro assigned to the ActiveX control's Click event to select a specified cell for you.

To select a cell in a macro, add a statement similar to either of the following in the Click event procedure of your ActiveX control. ActiveCell.Select

-or-

Range("A1").Select



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

Additional query words: XL2000 ipf gpf crash crashes crashing crashed quit quitting quits fail fails failing failed break hang freeze stops responding radio button check box option list combo toggle

Keywords: kberrmsg kbbug kbpending KB231129

-

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

© Microsoft Corporation. All rights reserved.