Windows Script Host Invalid Procedure Call Or Argument Essay

All occurrences of function in your code follow syntax pattern properly:


  • String expression from which characters are returned. If string contains , is returned.
  • Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string ().
  • Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the position to the end of the string are returned.

Excerpted from the original code snippet, variables renamed merely for clearness:

On the other side, function would fail raising terminating error if or are out of range.

Let's consider some valid UNC paths as possible values of variable:

  • , , , : the original function would not fail,
  • but for instance raises error in question as specified i.e. results to a negative number.

should resolve the latter issue although someone could find a valid UNC path such that or would lead to the error?

Answer, returned to original variable names, use next improved command:

answered Jan 3 '17 at 14:00

This documentation is archived and is not being maintained.

Visual Basic for Applications Reference

Invalid procedure call or argument (Error 5)

See Also    Specifics

Some part of the call can't be completed. This error has the following causes and solutions:

  • An argument probably exceeds the range of permitted values. For example, the Sin function can only accept values within a certain range. Positive arguments less than 2,147,483,648 are accepted, while 2,147,483,648 generates this error.

    Check the ranges permitted for arguments.

  • This error can also occur if an attempt is made to call a procedure that isn't valid on the current platform. For example, some procedures may only be valid for Microsoft Windows, or for the Macintosh, and so on.

    Check platform-specific information about the procedure.

For additional information, select the item in question and press F1.

This documentation is archived and is not being maintained.


Leave a Reply

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