Delphi Error – E2166 Unnamed arguments must precede named arguments in OLE Automation call

Delphi Compiler Error

E2166 Unnamed arguments must precede named arguments in OLE Automation call

Reason for the Error & Solution

You have attempted to follow named OLE Automation arguments with unnamed arguments.

program Produce;

  var
    ole : variant;

begin ole.dispatch(filename:='FrogEggs', 'Tapioca');
end.

The named argument, ‘filename’ must follow the unnamed argument in this OLE dispatch.

program Solve;

  var
    ole : variant;

begin ole.dispatch('Tapioca', filename:='FrogEggs');
end.

This solution, reversing the parameters, is the most straightforward but it may not be appropriate for your situation. Another alternative would be to provide the unnamed parameter with a name.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...