Invalid use of AddressOf operator

The AddressOf operator modifies an argument to pass the address of a function rather than passing the result of the function call. This error has the following cause and solution:

  • You tried to use AddressOf with the name of a class method. Only the names of Visual Basic procedures in a .bas module can be modified with AddressOf. You can't specify a class method.

  • The procedure name modified by AddressOf is defined in a module in a different project.

  • You tried to modify the name of a DLL function or a function defined in a type library with AddressOf.

  • DLL and type library functions can't be modified with AddressOf. The procedure definition must be in a module in the current project. Move the definition to a module in this project or include its current module in the project.

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

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.