I have a COM object written in Delphi that has a property that returns a variant. Basically this property returns a value depending on the parameter I pass it. When I access the object from VBA (Excel for example), I can write something like :
MyObject.MyProperty("IntProperty") = 22
Now the property can also return an IDispatch object, which is stored in the variant. If I access the com object from Delphi, I write the following code to extract that IDispatch information
var
Info : IMyInterface;
Info := IDispatch(TVarData(MyObject.MyProperty['InfoProperty']).VDispatch) as IMyInterface;
Info.foo := 10;
info.y := 'test';
info.saveit;
Is it possible to extract that IDispatch information in VBA? I haven't figured out a way to do it yet.
To be 100% clear, the property is of type OLEVariant, and not IDispatch. I have properties that are of type IDispatch, and they work fine.
This is the declaration of get_MethodProperty
function get_MethodProperty(const aPropertyName: WideString):OLEVariant;
It would work if I declared it as
function get_MethodProperty(const aPropertyName: WideString):IDispatch;
But that is not what I want.
This is the VBA code, and it fails on the second line
Dim Info as Object
Set Info = MyObject.MethodProperty("InfoProperty")
Info.foo = 10
Info.y = "test"
call info.saveit