Article ID: 213546 - Last Review: October 10, 2006 - Revision: 3.2 XL2000: Parentheses Around Object May Dereference the ObjectThis article was previously published under Q213546 On This PageSYMPTOMS
You may receive a run-time error or unexpected results from your macro if you enclose the argument for a procedure in parentheses when a value is not returned from the procedure. You may receive one of the following error messages:
Run-time error '438': Object doesn't support this property or method
-or-
Run-time error '424': Object Required CAUSE
You may receive one of these error messages if you enclose an object
variable with parentheses when passing the object variable to another function or procedure. When an object variable is enclosed in parentheses
and a return value is not expected, the object variable is "dereferenced."
In other words, the Value property for the object is passed to the
procedure instead of the object itself. This can produce either a run-time
error or unexpected results.
RESOLUTION
To correct this problem, do not use parentheses around object variables
that are passed to a function or procedure when a return value is not
expected. Parentheses should only be used around object variables when a
return value is needed.
For example, this line produces an error in Microsoft Excel because the Worksheet object is dereferenced. MORE INFORMATION
This section describes several scenarios where your macro may fail or
behave unexpectedly because of dereferencing of an object variable.
Example 1Example 2Example 3The following example simply demonstrates how you can visualize the difference between an object that is dereferenced and one that is not.REFERENCESFor more information about parentheses in your macros, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Using Parentheses in Code in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
| Article Translations
|
Back to the top
