VBA Error Codes

This Appendix contains a complete listing of the error codes for all trappable errors in Visual Basic for Applications (VBA). This information is useful for error trapping. For complete details, consult Excel's online help.

Error Code Message

3 Return without GoSub.

5 Invalid procedure call or argument.

6 Overflow (for example, value too large for an integer).

7 Out of memory. This error rarely refers to the amount of physical memory installed on your system. Rather, it usually refers to a fixed-size area of memory used by Excel or Windows (for example, the area used for graphics or custom formats).

9 Subscript out of range. You will also get this error message if a named item is not found in a collection of objects: For example, if your code refers to Sheets("Sheet2"), and Sheet2 does not exist.

10 This array is fixed or temporarily locked.

11 Division by zero.

13 Type mismatch.

14 Out of string space.

16 Expression too complex.

17 Can't perform requested operation.

18 User interrupt occurred. This error occurs if the user interrupts a macro by pressing the Cancel key.

20 Resume without error. This error probably indicates that you forgot the

Exit Sub statement before your error handler code.

28 Out of stack space.

35 Sub or Function not defined.

Error Code

59 61 62 63

76 91


Too many Dynamic Link Library (DLL) application clients.

Error in loading DLL.

Bad DLL calling convention.

Internal error.

Bad filename or number.

File not found.

Bad file mode.

File already open.

Device Input/Output (I/O) error.

File already exists.

Bad record length.

Disk full.

Input past end of file. Bad record number. Too many files. Device unavailable. Permission denied. Disk not ready.

Can't rename with different drive. Path/File access error. Path not found.

Object variable or With block variable not set. This error occurs if you don't use Set at the beginning of a statement that creates an object variable. Or, it occurs if you refer to a worksheet object (such as ActiveCell) when a chart sheet is active.

For loop not initialized.

Invalid pattern string.

Invalid use of Null .

Error Code Message

96 Unable to sink events of object because the object is already firing events to the maximum number of event receivers that it supports.

97 Cannot call friend function on object that is not an instance of defining class.

98 A property or method call cannot include a reference to a private object, either as an argument or as a return value.

321 Invalid file format.

322 Can't create necessary temporary file. 325 Invalid format in resource file.

380 Invalid property value.

381 Invalid property array index.

382 Set not supported at runtime.

383 Set not supported (read-only property). 385 Need property array index.

387 Set not permitted.

393 Get not supported at runtime.

394 Get not supported (write-only property).

422 Property not found.

423 Property or method not found.

424 Object required. This error occurs if text preceding a dot is not recognized as an object.

429 ActiveX component can't create object (might be a registration problem with a library that you've referenced).

430 Class doesn't support Automation or doesn't support expected interface. 432 Filename or class name not found during Automation operation.

438 Object doesn't support this property or method.

440 Automation error.

442 Connection to type library or object library for remote process has been lost. Press OK for dialog box to remove reference.

Error Code Message

443 Automation object does not have a default value.

44 5 Object doesn't support this action.

446 Object doesn't support named arguments.

447 Object doesn't support current locale setting.

448 Named argument not found.

449 Argument not optional.

450 Wrong number of arguments or invalid property assignment.

451 Property Let procedure not defined, and Property Get procedure did not return an object.

452 Invalid ordinal.

453 Specified DLL function not found.

454 Code resource not found.

455 Code resource lock error.

457 Key is already associated with an element of this collection.

458 Variable uses an Automation type not supported in Visual Basic.

459 Object or class does not support the set of events.

460 Invalid Clipboard format.

461 Method or data member not found.

462 Remote server machine doesn't exist or is unavailable.

463 Class not registered on local machine.

481 Invalid picture.

482 Printer error.

735 Can't save file to TEMP.

744 Search text not found.

746 Replacements too long.

1004 Application-defined or object-defined error. This is a very common catch-all error message. This error occurs when an error doesn't correspond to an error defined by VBA. In other words, the error is defined by Excel (or some other object) and is propagated back to VBA.

Appendix D

0 0


  • nebay
    Can not call friend function on object which is not an instance of defining class?
    8 years ago

Post a comment