XL5: GP Fault Running Macro That Passes Argument to Sub

Last reviewed: September 12, 1996
Article ID: Q120043
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c

SYMPTOMS

In Microsoft Excel, you receive a general protection (GP) fault when you run a Visual Basic procedure that passes an argument to another

sub procedure, if the sub procedure closes the workbook that contains
the calling procedure.

CAUSE

For example, this problem occurs if you use the following syntax to call the sub procedure "Update" with the argument "1":

   Application.Run "Update(1)"

-or-

   Application.Run("Update(1)")

If the procedure Update in the above example closes the workbook that contains the Application.Run command (the calling procedure), you receive a GP fault. The problem occurs whether the procedures are stored in the same workbook, or different workbooks.

WORKAROUND

To avoid receiving a GP fault when you call a sub procedure with an argument, when the sub procedure closes the workbook that contains the calling procedure, use the following syntax to call the sub procedure:

   Application.Run "Update", 1

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel version 7.0.

Note that in Microsoft Excel version 5.0c, if you use the syntax that causes the problem described above, you do not receive a GP fault, however, the sub procedure may not run as expected.

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

   ARTICLE-ID: Q118881
   TITLE     : XL5: Unexpected Results Calling Sub Procedure with Arguments


KBCategory: kbprg
KBSubcategory:

Additional reference words: 1.00 5.00 gpf



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