Does VBScript allow named arguments in function calls?

VBScript doesn’t support named arguments to procedures and functions. You need to change the argument list to positional:

Workbooks.OpenText Filename_Argument, xlMSDOS, ...

VBScript also doesn’t recognize Excel constants (like xlMSDOS), so you need to look them up and replace them with their numeric values:

Workbooks.OpenText Filename_Argument, 3, ...

And you must use explicit object references:

objExcel.Workbooks.OpenText Filename_Argument, 3, ...

The Excel Macro Recorder puts named arguments into positional order, so you can just delete the parameter names. Optional parameters that you don’t want to specify can be omitted, e.g.:

x = Function(Var1, , Var3)
'                 ^
'                 `- omitted optional 2nd parameter

Leave a Comment