I cannot figure out how to access object properties in an array using VBA. I have created an array like:
Dim objectArray(10) as Variant
Dim counter as Integer 'used to move to next element in array
Next, I declared an object and store it in the array:
Dim object as Variant
objectArray(0) = object 'object stored in array
counter = counter + 1 'increment counter
I want to pass the array to a function.
That function receives the array of objects like:
Public function(objectArray() as Variant)
So far, it seems to have worked when I have debugged it. My objectArray() seems to contain the object. When I store one object in the array, the debuger shows
objectArray(0)(1,1) .... 'this is in the Watch section of the debugger
I want to access the properties of that object in the first position of the array. That object will contain a name, several values, and a date. I've been trying to access the properties on that object like
Dim separateVar as Variant 'declare new var to hold "name"
separateVar = objectArray(0)(1,1).Value
However, when I run the macro, I get "Some Error Occured, 13, Type Mismatch". Am I accessing the object property values incorrectly?
Any help would be appreciated. Finding articles about accessing objects is easy, but finding ones about accessing their individual properties has been very difficult.