Invalid outside procedure

The statement must occur within a Sub or Function, or a property procedure (Property Get, Property Let, Property Set). This error has the following cause and solution:

  • An executable statement, Static or ReDim, appears at module level.

    Static is unnecessary at module level, since all module-levelvariables are static. Use Dim instead of ReDim at module level. To create a dynamicarray at module level, declare it with Dim using empty parentheses.

    Note At module level, you can use only comments and declarative statements, such as Const, Declare, Deftype, Dim, Option Base, Option Compare, Option Explicit, Option Private, Private, Public, and Type. The Sub, Function, and Property statements occur outside the body of theirprocedures, but within the procedure declaration.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).