I am getting the following message when trying to return a new object to VBA from my Visual Foxpro COM server. "Run-time error '-2147417851 (80010105)':
Method 'ReturnObject' of object 'Itestclass' failed"
If I remove the "Dim ... As" line the error goes away but then I lose intellisense for the COM object.
This is the VBA code:
'' Removing the following line gets rid of the error but loses intellisense for the COM object
Dim objTest As testcom.TestClass
Set objTest = CreateObject("TestCOM.TestClass")
Set objNew = objTest.ReturnObject '' This is the line that causes the error
I have created a link to the TestCOM type library in Tools > References
Here is the Visual Foxpro (VFP) code: The COM server is being built as an out of process EXE. If I build it as an inprocess .DLL then the VBA code causes Excel to crash.
DEFINE CLASS ObjectToReturn AS SESSION OLEPUBLIC
DEFINE CLASS TestClass AS SESSION OLEPUBLIC
I have tried changing the RETURN CREATEOBJECT("ObjectToRetu
rn") to RETURN CREATEOBJECT("CUSTOM") but the problem persists.
Please advise how I can get rid of this error without losing the intellisense for the COM object in VBA. Thanks
I have tried creating a public Collection in TestClass and using that and I have tried using SYS(3097) to keep a reference to the object in VFP but the problem perists.