Source Property (Visual Basic for Applications)

Microsoft Visual Basic Constants

Source Property

           

Returns or sets a string expression specifying the name of the object or application that originally generated the error. Read/write.

Remarks

The Source property specifies a string expression representing the object that generated the error; the expression is usually the object's class name or programmatic ID. Use Source to provide information when your code is unable to handle an error generated in an accessed object. For example, if you access Microsoft Excel and it generates a Division by zero error, Microsoft Excel sets Err.Number to its error code for that error and sets Source to Excel.Application.

When generating an error from code, Source is your application’s programmatic ID. For class modules, Source should contain a name having the form project.class. When an unexpected error occurs in your code, the Source property is automatically filled in. For errors in a standard module, Source contains the project name. For errors in a class module, Source contains a name with the project.class form.