Application-defined or object-defined error
This message is displayed when an error generated with the Raise method or Error statement doesn't correspond to an error defined by Visual Basic for Applications. It is also returned by the Error function for arguments that don't correspond to errors defined by Visual Basic for Applications. Thus it may be an error you defined, or one that is defined by an object, including host applications like Microsoft Excel, Visual Basic, and so on. For example, Visual Basic forms generate form-related errors that can't be generated from code simply by specifying a number as an argument to the Raise method or Error statement. This message has the following causes and solutions:
Your application executed an Err.Raise n or Error n statement, but the number n isn't defined by Visual Basic for Applications. If this was what was intended, you must use Err.Raise and specify additional arguments so that an end user can understand the nature of the error. For example, you can include a description string, source, and help information. To regenerate an error that you trapped, this approach will work if you don't execute Err.Clear before regenerating the error. If you execute Err.Clear first, you must fill in the additional arguments to the Raise method. Look at the context in which the error occurred, and make sure you are regenerating the same error.
It may be that in accessing objects from other applications, an error was propagated back to your program that can't be mapped to a Visual Basic error.
Check the documentation for any objects you have accessed. The Err object's Source property should contain the programmatic ID of the application or object that generated the error. To understand the context of an error returned by an object, you may want to use the On Error Resume Next construct in code that accesses objects, rather than the On Error GoTo line syntax.
In the past, programmers often used a loop to print out a list of all trappable error message strings. Typically this was done with code such as the following:
Such code still lists all the Visual Basic for Applications error messages, but displays "Application-defined or object-defined error" for host-defined errors, for example those in Visual Basic that relate to forms, controls, and so on. Many of these are trappable run-time errors. You can use the Help Search dialog box to find the list of trappable errors specific to your host application. Click Search, type Trappable in the first text box, and then click Show Topics. Select Trappable Errors in the lower list box and click Go To.
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).