I decided to convert my VBA XLAM add-in to VB6 COM DLL and did so. Most functions work well except those that involve passing excel objects.
As a simple example consider the following.
The above is a simple function defined in VB6 COM DLL named say MyDLL in a class named say myDClass. The project is compiled into a DLL and a reference to it is added from within Excel VBA project. The below is the VBA wrapper to the above DLL function.
When I call the above function and debug it from within VB6 and VBA both, I can see that the range object is passed to the DLL and the DLL function is able to operate on it and return the row count successfully (from within VB6 IDE). But once the function call returns back to VBA, the return value is empty and ReturnRowCount above returns zero even though dllReturnRowCount succeeded. I can get other functions that do not involve passing Excel objects to return values of types Date, String, Boolean etc. successfully.
So, the question is how do I get the above to work the way it should ? What am I doing wrong ?
Thanks for any help.
As a simple example consider the following.
Code:
<code>Public Function dllReturnRowCount(rDataRange as Excel.Range) as Long
dllReturnRowCount = rDataRange.Rows.Count
End Function</code>
The above is a simple function defined in VB6 COM DLL named say MyDLL in a class named say myDClass. The project is compiled into a DLL and a reference to it is added from within Excel VBA project. The below is the VBA wrapper to the above DLL function.
Code:
<code>
Function ReturnRowCount(rDataRange as Range) as Long
Dim myDllFunc as MyDLL.myDClass
Set myDllFunc = New MyDLL.myDClass
ReturnRowCount = myDllFunc.dllReturnRowCount (rDataRange)
End Function</code>
So, the question is how do I get the above to work the way it should ? What am I doing wrong ?
Thanks for any help.