nitt1995
07-13-2006, 08:27 AM
I have set up a class module in an add in which contains the blue print of a set of variables and methods to act on those variables.
I would like to instatiate this object from other projects. Is this possible? I have added the reference to the Add-in from Tools->References but cannot DIM a new object to this class module.
The following code works when both modules are in the same worksheet, but not in different workbooks. I know that it shouldn't work unless I can properly reference the class module of workbook A to the module on workbook B, but I can't figure out the syntax.
This code goes into a class module on workbook A. Call this class module "SumClass"
Option Explicit
Public x As Double
Public y As Double
Function sum() As Double
sum = x + y
End Function
This code goes into a standard module on workbook B.
Option Explicit
Dim test As SumClass
Sub main()
Set test = New SumClass
test.x = 3
test.y = 4
MsgBox Prompt:=test.sum 'Should output 7
End Sub
So basically, I need to know how to reference "SumClass" from workbook B.
I would like to instatiate this object from other projects. Is this possible? I have added the reference to the Add-in from Tools->References but cannot DIM a new object to this class module.
The following code works when both modules are in the same worksheet, but not in different workbooks. I know that it shouldn't work unless I can properly reference the class module of workbook A to the module on workbook B, but I can't figure out the syntax.
This code goes into a class module on workbook A. Call this class module "SumClass"
Option Explicit
Public x As Double
Public y As Double
Function sum() As Double
sum = x + y
End Function
This code goes into a standard module on workbook B.
Option Explicit
Dim test As SumClass
Sub main()
Set test = New SumClass
test.x = 3
test.y = 4
MsgBox Prompt:=test.sum 'Should output 7
End Sub
So basically, I need to know how to reference "SumClass" from workbook B.