XL5: "Invalid Inside Procedure" Using Declare Statement

ID: Q120374


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


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

Additional query words:

Keywords :
Version : 5.00
Platform : WINDOWS
Issue type :


Last Reviewed: September 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.