XL5: "Invalid Inside Procedure" Using Declare Statement

Last reviewed: September 12, 1996
Article ID: Q120374
The information in this article applies to:
  • Microsoft Excel for Windows, versions 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


KBCategory:
KBSubcategory:

Additional reference words: 5.00



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.