XL5: GP Fault Running Macro That Passes Argument to Sub

ID: Q120043

5.00 5.00c WINDOWS kbprg

The information in this article applies to:

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

Version           : 5.00 5.00c
Platform          : WINDOWS

Last Reviewed: September 14, 1996