[Invoke VBA] How to read the retrieved COM__Object in UiPath? VBA Function returns custom type

Hi I found these threads here:

The first one didn’t get a single answer that’s why I’m here. I found out that you can not retrieve a Collection via Invoke VBA as stated in this documentation: https://support.microsoft.com/de-ch/help/323737/bug-error-message-when-you-try-to-pass-a-collection-object-from-visual

I now try to do it with my own class in VBA. My class consists of (String, String, Bool) and I want to return this to the VBA function and then use it in UIPath. I tried to treat it as an object and then read its properties like this: vb.net - Loop through values of properties of an object? - Stack Overflow
but it also doesn’t work.

How can I read the retrieved COM Object so I can use its values/access members of my VBA class in UIPath?

Thanks.

2 Likes

Dirty workaround - have you considered passing a string representation (i.e. Json) of the object instead and deserializing it in UiPath as for example Tuple(Of String, String, Boolean) or a custom type?

I thought of many ways to create a “hack” but I strongly want to avoid a hack.
I could also create a CSV or as you said a string representation or simply make all of them a String and put them in a String array but that’s extremely ugly and I’m 100% sure there is a way without a hack.

Actually I found a solution to read the members of my own class: C#: Using reflection with COM objects | Mehroz's Experiments

//get the value of comObject.PropertyName
object propertyValue = comObject.GetType().InvokeMember("PropertyName", System.Reflection.BindingFlags.GetProperty, null, comObject, null);

//set the value of comObject.PropertyName
comObject.GetType().InvokeMember("PropertyName", System.Reflection.BindingFlags.SetProperty, null, comObject, new object[] { propertyValue });

The only problem I have now is to be able to read it as a collection.
EDIT: I gave up on the collection.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.