Microsoft KB Archive/120374

{|
 * width="100%"|

XL5: "Invalid Inside Procedure" Using Declare Statement

 * }

-

The information in this article applies to:


 * Microsoft Excel for Windows, version 5.0

-

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).