Hi all,
I’m writing something in Lotusscript where I would like to pass a custom class to a macro in Excel. I’ve managed to get a handle to Excel, but when I pass the class, I get a “Type Mismatch” error. Any ideas?
Hi all,
I’m writing something in Lotusscript where I would like to pass a custom class to a macro in Excel. I’ve managed to get a handle to Excel, but when I pass the class, I get a “Type Mismatch” error. Any ideas?
Subject: Passing custom class from Lotusscript to VBA
Randall,
Could you post the code? Thanks.
Brandt
Subject: RE: Passing custom class from Lotusscript to VBA
****Here is an excerpt from the class definition, which is in the declarations section of a LotusScript action:
Class Cat
CatName As String
Usage As String
Action As String
Public Sub new()
End Sub
Public Function GetCatName() As String
GetCatName = Me.CatName
End Function
Public Function SetCatName(strg As String)
Me.CatName = strg
End Function
End Class
Here is the relevant LotusScript code in the action:
Dim xlapp as Variant
Set xlapp = CreateObject(“Excel.Application”)
xlapp.workbooks.open(“H:\data\My Documents\Computing\Lotus Notes\To Be Opened By Lotus.xls”)
Dim catTest As New Cat
catTest.SetCatName(“Cat1”)
xlapp.run “testCatClass”, catTest
And the VBA code is:
Sub testCatClass(ByRef catTest As Cat)
MsgBox catTest.GetCatName
End Sub
[By the way, I get the same error when I change the VBA to (ByRef catTest as Variant)]
Subject: RE: Passing custom class from Lotusscript to VBA
Randall,
I am pretty sure that you would have to define your class in VBA, because as you state, your class exists in the declarations for your action and is limited in scope to that action. Excel will have no idea what a Cat object is, because when you pass the object through LS, the code that is the brains of the operation isn’t passed to VBA.
I doubt that even if you did define Cat in VBA that this would work. I would assume that unless you write a custom lsx (which I do not have the skill level to do) both LS and VBA are going to be limited to how they can handle this class.
sorry.
brandt
Subject: RE: Passing custom class from Lotusscript to VBA
Thanks for your help, Brandt. I guess I’ll figure out a way to not use the class.