Article ID: 142138 - View products that this article applies to.
This article was previously published under Q142138
This article a contains detailed descriptions of the trappable error messages that can be used with the Err function in Visual Basic for Applications.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Return without GoSub (Error 3)A Return statement does not have a corresponding GoSub statement. Unlike For...Next, While...Wend, and Sub...End Sub, which are matched at compile time, GoSub and Return are matched at run time.
Invalid procedure call (Error 5)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 2147483648 are accepted, while 2147483648 generates this error.
This error may also occur if an attempt is made to call a procedure that is not valid on the current platform. For example, some procedures may only be valid for the Macintosh, or for Microsoft Windows, and so forth.
Overflow (Error 6)Possible causes for this error are:
Out of memory (Error 7)More memory was required than is available or a 64K segment boundary was encountered. To prevent this error, try the following:
Subscript out of range (Error 9)You have referenced a nonexistent array element or collection member. The subscript may be larger or smaller than the range of possible subscripts, or the array may not have dimensions assigned at this point in the application.
Duplicate definition (Error 10)This error usually occurs only when generated from code, as in the following example:
However the error may also occur if you try to use ReDim to change the number of elements of a fixed-size array. For example, in the following code, the fixed array FixedArr is received by SomeArr in the procedure NextOne, then an attempt is made to resize SomeArr:
Division by zero (Error 11)The value of an expression being used as a divisor is zero. Check the spelling of variables in the expression. A misspelled variable name can implicitly create a numeric variable that is initialized to zero. Check previous operations on variables in the expression, especially those passed into the procedure as arguments from other procedures.
Type mismatch (Error 13)Possible causes for this error are:
Out of string space (Error 14)Your system may have run out of memory, which has prevented a string from being allocated. Similarly, expressions requiring that temporary strings be created for evaluation may be causing this error. For example, the following code will cause an Out of string space error:
MyString = "Hello" For Count = 1 To 100 MyString = MyString & MyString Next Count
Visual Basic lets you allocate a string with a maximum length of 65,535 characters. However, in executing statements at run time, the host application needs to use some string space for overhead. The amount of overhead varies among hosts, but should not exceed 50 bytes. If you need to allocate a string of the maximum length your host can support, reduce the string size by 50 bytes, then increase the length incrementally until this error is generated again. The value immediately preceding the error represents the host's maximum string length.
String formula too complex (Error 16)A string expression is too complicated. Strings not assigned to variables (such as those returned by functions) are assigned to temporary locations during string expression evaluation. Having a large number of these strings can cause this error. Try assigning these strings to variables and use the variables in the expression instead.
Can't perform requested operation (Error 17)The requested operation can't be performed because it would invalidate the current state of the project. For example, the error occurs if you use the References dialog box (on the Tools menu, click Rererences) to add a reference to a new project or object library while a program is in break mode.
User interrupt occurred (Error 18)A CTRL+BREAK or other interrupt key has been pressed by the user.
Resume without error (Error 20)A Resume statement has been encountered, but it is either outside the error handler code, or it was encountered while there was no error-handling routine active.
Out of stack space (Error 28)Possible causes for this error are:
Sub or function not defined (Error 35)A Sub, Function, or Property procedure is called but is not defined.
Possible causes for this error are:
Error in loading DLL (Error 48)The specified dynamic-link library (DLL) can't be loaded. This is usually because the file specified with the Lib clause in the Declare statement is not a valid DLL.
Possible causes for this error are:
Bad DLL calling convention (Error 49)Your program is calling a routine in a dynamic-link library (DLL) that either is being passed the wrong type or number of arguments or does not use the Pascal calling convention. Make sure that the arguments passed to the DLL routine exactly match the arguments expected by the routine. If the DLL routine expects arguments by value, then make sure ByVal is specified for those arguments in the declaration for the routine.
Internal error (Error 51)An internal malfunction has occurred in Visual Basic. Unless this call was generated by the Error statement, contact Microsoft Product Support Services to report the conditions under which the message appeared.
Bad file name or number (Error 52)A statement refers to a file with a file number or file name that is:
File not found (Error 53)Possible causes for this error at run time are:
Bad file mode (Error 54)Possible causes for this error are:
File already open (Error 55)Possible causes for this error are:
Device I/O error (Error 57)An input or output error occurred while your program was using a device such as a printer or disk drive.
File already exists (Error 58)At run time, this error occurs when the new file name (for example, one specified in a Name statement) is identical to a file name that already exists. It also occurs when you use Save As to save a currently loaded project if the project name already exists.
Bad record length (Error 59)The length of a record variable for a Get or Put statement does not match the length specified in the corresponding Open statement. Because a two- byte descriptor is always added to a variable-length string Put to a random access file, the variable-length string must be at least two characters shorter than the record length specified in the Len clause of the Open statement.
Variant data types also require a two-byte descriptor. Variants containing variable-length strings require a four-byte descriptor. Therefore, for variable-length strings in a Variant, the string must be at least 4 bytes shorter than the record length specified in the Len clause.
Disk full (Error 61)Possible causes for this error are:
Input past end of line (Error 62)An Input # or Line Input # statement is reading from a file in which all data has already been read or from an empty file. To avoid this error, use the EOF function (immediately before the Input # statement) to detect the end of file.
Bad record number (Error 63)The record number in a Put or Get statement is less than or equal to zero.
Too many files (Error 67)Possible causes for this error are:
Device unavailable (Error 68)The device you are trying to access is either not online or does not exist.
Permission denied (Error 70)An attempt was made to write to a write-protected disk or to access a locked file. For example, this error will occur if an Open For Output statement is performed on a write-protected file.
Disk not ready (Error 71)There is either no disk in the drive specified or the drive door is open. Insert a disk in the drive, close the door, and retry the operation.
Can't rename with different drive (Error 74)You can't use the Name statement to rename a file with a new drive designation. Use FileCopy to write the file to another drive, and delete the old file with a Kill statement.
Path/File access error (Error 75)During a file- or disk-access operation (for example, Open, MkDir, ChDir, or RmDir), the operating system could not make a connection between the path and the file name.
Make sure the file specification is formatted correctly. A file name can contain a fully-qualified or relative path. A fully-qualified path starts with the drive name (if the path is on another drive) and lists the explicit path from the root to the file. Any path that is not fully qualified is relative to the current drive and directory. This error can also occur while attempting to save a file that would replace an existing read-only file.
Path not found (Error 76)During a file- or disk-access operation (for example, Open, MkDir, ChDir, or RmDir), the operating system was unable to find the specified path. The error also occurs in the debugging environment if you attempt to open a project or insert a text file with an invalid path. Make sure the path is typed correctly.
Object variable not set (Error 91)You are attempting to use an object variable that is not yet referencing a valid object, or one that has been set to Nothing. Specify or respecify a reference for the object variable. For example, if the Set statement were omitted in the following code, an error would be generated:
Dim MyObject As Object ' Creates object variable. Set MyObject = Sheets(1) ' Creates valid object reference. MyCount = MyObject.Count ' Assigns Count value to MyCount.
For Loop not initialized (Error 92)You've jumped into the middle of a For...Next loop. Placing labels inside a For...Next loop is not recommended.
Invalid pattern string (Error 93)The pattern string specified in the Like operation of a search is invalid. A common example of an invalid character list expression is [a-b , where the right bracket is missing.
Invalid use of Null (Error 94)You are trying to obtain the value of a variant variable or an expression that is Null. Null is a variant subtype used to indicate that a data item contains no valid data. For example:
MyVar = Null For Count = 1 To MyVar . . . Next Count
Can't load module; invalid format (Error 323)The module you attempted to load is not a text module. Some versions of Visual Basic permit you to save code in both binary and text formats. If possible, reload the file in the application in which it was last saved and save it as text. This error code applies to Microsoft Excel for Windows 95, version 7.0 only.
Property or method not found (Error 423)Object.method or object.property is referred to, but method or property is not defined, or you may have misspelled the name of the object. To see what properties and methods are defined for an object, choose the Object Browser from the View menu. Select the appropriate library and object to display available properties and methods.
Object required (Error 424)You have referred to an object property or method, but have not provided a valid object qualifier.
Class doesn't support OLE Automation (Error 430)The object specified in the GetObject or CreateObject function call was found, but has not exposed a programmability interface. Therefore you can't write code to control this object's behavior. Check the documentation of the application that created the object for limitations on the use of OLE Automation with this class of object.
Object doesn't support this property or method (Error 438)This method or property does not exist for this OLE automation object. See the object's documentation for more information on the object and to check the spellings of properties and methods.
OLE Automation error (Error 440)An error occurred while executing a method or accessing a property of an object variable. The error was reported by the application that created the object.
Object doesn't support this action (Error 445)This method or property is not supported by this object. See the object's documentation for more information on the object and to check the spellings of properties and methods.
Object doesn't support named arguments (Error 446)Arguments can only be specified by position when performing methods on this object. See the object's documentation for more information on argument positions and types.
Object doesn't support current locale settings (Error 447)The object you are attempting to access does not support the locale setting for the current project. For example, if your current project has the locale setting Canadian French, the object you are trying to access must support that locale setting. Check which locale settings the object supports.
Also note that the object may rely on national language support in a dynaminc-link library (DLL), for example OLE2NLS.DLL. If so, you may need a more recent version that supports the current project locale.
Named argument not found (Error 448)You specified a named argument, but the procedure was not defined to accept an argument by that name. Check the spelling of the argument name.
Argument not optional (Error 449)The number and types of arguments must match those expected. For instance, the Left function requires two arguments, the first representing the character string being operated on, and the second representing the number of characters to return from the left side of the string. Because neither argument is optional, both must be supplied.
An argument can only be omitted from a call to a user-defined procedure if it was declared Optional in the procedure declaration.
Wrong number of arguments (Error 450)The number of arguments in the call to the procedure was not the same as the number of arguments expected by the procedure. Check the argument list in the call against the procedure declaration.
Object not a collection (Error 451)You have specified an operation or property that is exclusive to collections, but the object is not a collection. Check the spelling of the object or property name, or verify that the object is a collection.
Invalid ordinal (Error 452)Your call to a dynamic-link library (DLL) indicated to use a number instead of a procedure name, using the #num syntax. However, an attempt to convert the expression num to an ordinal failed, or the num specified does not specify any function in the DLL. Check to make sure the expression represents a valid number, or call the procedure by name.
Specified DLL function not found (Error 453)The dynamic-link library (DLL) in a user library reference was found, but the DLL function specified was not found within the DLL. An invalid ordinal may have been specified in the function declaration. Also, the DLL may have the right name but is not the version that contains the specified function.
Code resource not found (Error 454)A call was made to a procedure in a code resource, but the code resource could not be found. This error can only occur on the Macintosh operating system.
Code resource lock error (Error 455)A call was made to a procedure in a code resource. The code resource was found, but an error occurred when an attempt was made to lock the resource. Check for an error returned by HLock (for example, "Illegal on empty handle" or "Illegal on free block"). This error can only occur on the Macintosh operating system.
[Object] does not have [property name] property (Error 1000)The property does not exist for this object. To see a list of properties for this object, choose Object Browser from the View menu, and click the question mark button in the Object Browser dialog box to display the Visual Basic Help topic for this object.
[Object] does not have [method name] method (Error 1001)The method does not exist for this object. To see a list of methods for this object, choose Object Browser from the View menu, and click the question mark button in the Object Browser dialog box to display the Visual Basic Help topic for this object.
Missing required argument [argument] (Error 1002)The method expected a required argument that does not exist. Add the argument to the code. To see a list of required arguments, choose Object Browser from the View menu, and click the question mark button in the Object Browser dialog box to display the Visual Basic Help topic.
Invalid number of arguments (Error 1003)The method has the wrong number of arguments. This usually occurs when you use comma-separated position arguments (instead of named arguments), and you have too many arguments.
To see the valid arguments for this method, choose Object Browser from the View menu, and click the question mark button in the Object Browser dialog box to display the Visual Basic Help topic for this method.
[Method name] method of [object] class failed (Error 1004)An external error occurred, such as a failure to read or write from a file. The method cannot be used on the object. Possible reasons include the following:
Unable to set the [property name] property of the [object] class (Error 1005)The property cannot be changed. Possible reasons include the following:
Unable to get the [property name] property of the [object] class (Error 1006)The property cannot be changed. Possible reasons include:
For more information about error codes, choose the Search button in Help and type:
Article ID: 142138 - Last Review: October 11, 2006 - Revision: 3.3
Contact us for more help
Connect with Answer Desk for expert help.