XL5: "Invalid Inside Procedure" Using Declare Statement

ID: Q120374

5.00 WINDOWS

The information in this article applies to:

SYMPTOMS

In Microsoft Excel version 5.0, if you create a Visual Basic, Applications Edition, procedure using the Declare statement to make a Windows API call, you may receive the following error message:

   Invalid inside procedure

If you choose the OK button in the error dialog box, the Declare statement will be highlighted in your macro.

CAUSE

The "Invalid inside procedure" message does not necessarily mean that the Declare statement itself is incorrect; it means that the Declare statement is not allowed within a procedure. The Declare, Def, Private, Public, Option Base, Option Compare, Option Explicit, Option Private, and Type statements are only allowed outside the procedure.

WORKAROUND

To work around this problem, move the Declare statement outside of the procedure(that is, include it above the Sub statement in the declarations section of the module).

REFERENCES

For more information on the Declare statement, choose Contents from the Help menu, and choose Programming with Visual Basic. Choose the Search button in Help and type:

   Declare


KBCategory: KBSubcategory:

Additional reference words: 5.00

Version           : 5.00
Platform          : WINDOWS

Last Reviewed: September 14, 1996