Named arguments not allowed

Named arguments aren't permitted in all situations. This error has the following causes and solutions:

  • You tried to specify a named argument as an array index, for example:

    MyVar = MyArray(MyNamedArg := 1) 
    
    

    Use an ordinary variable or constant expression as an array index.

  • You tried to specify a named argument with an object, for example:

    MyVar = MyObject(MyNamedArg := 1) 
    
    

    Use a variable or constant expression if the object requires an argument. For example, if the default for an object is a method, the object's name represents the default method. If it needs arguments, specify them positionally.

  • You tried to specify a named argument with an external name:

    MyVar = [MyName](MyNamedArg := 1) 
    
    

    Use an ordinary variable or constant expression if the external name needs an argument.

  • You tried to specify a named argument with a data member of an object, for example:

    MyVar = [MyObject].MyProperty(MyNamedArg := 1) 
    
    

    Use an ordinary variable or constant expression if the data member needs an argument.

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

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.