Returns a Boolean value indicating whether an expression references a valid OLE Automation object.
IsObject(expression)
The expression argument can be any expression.
IsObject returns True if expression is a variable of Object type (or a Variant of VarType vbObject, or a user-defined object); otherwise, it returns False.
IsArray Function, IsDate Function, IsEmpty Function, IsError Function, IsMissing Function, IsNull Function, IsNumeric Function, Object Data Type, Set Statement, TypeName Function, Variant Data Type, VarType Function.
This example uses the IsObject function to determine if a variable references a valid object. MyObject and YourObject are object variables of the same type. They are generic names used for illustration purposes only.
Dim MyInt As Integer ' Declare variables.MyObject As ObjectYourObject = MyObject ' Assign an object reference.= IsObject(YourObject) ' Returns True.= IsObject(MyInt) ' Returns False.
The following example uses the IsObject function to check whether an argument passed to the function is an object.
Sub CheckObject(varAny As Variant) Dim varX as Variant If IsObject(varAny) Then Set varX = varAny Else varX = varAny End IfSub