You can use the function varType()to check the type, otherwise, if you are testing certain types, you can use typeof.
If VarType(oCollection.Item(sKey)) = vbObject Then
Set vItem = oCollection.Item(sKey)
Else
vItem = oCollection.Item(sKey)
End If
source
share