Hi all,
You guys are great, and your forum is one of the most helpful things on the internet. I'm hoping you might be able to help me figure out why something I'm doing isn't working.
I'm trying to create a function that will compare a string value to the value of an arbitrary (specified) property of an object. Elsewhere online I've found several functions like this:
Which is apparently supposed to find the property specified by strPropName within the object. However, when I run this, I always get "Error 438: Object doesn't support this property or method." It seems to be complaining about the .Properties method, but I don't know why.
Can anyone give me some advice as to why .Properties doesn't work? Otherwise, is there any other way to access an property by name without hardcoding in the property?
(Note: I'm trying to avoid statements like obj.Name, obj.Path etc)
Your help is much appreciated!
You guys are great, and your forum is one of the most helpful things on the internet. I'm hoping you might be able to help me figure out why something I'm doing isn't working.
I'm trying to create a function that will compare a string value to the value of an arbitrary (specified) property of an object. Elsewhere online I've found several functions like this:
Code:
Public Function HasProperty(obj As Object, strPropName As String) As Boolean
'Purpose: Return true if the object has the property.
Dim varDummy As Variant
'On Error Resume Next
varDummy = obj.Properties(strPropName)
HasProperty = (Err.Number = 0)
End Function
Which is apparently supposed to find the property specified by strPropName within the object. However, when I run this, I always get "Error 438: Object doesn't support this property or method." It seems to be complaining about the .Properties method, but I don't know why.
Can anyone give me some advice as to why .Properties doesn't work? Otherwise, is there any other way to access an property by name without hardcoding in the property?
(Note: I'm trying to avoid statements like obj.Name, obj.Path etc)
Your help is much appreciated!