Hi,
I’m new to VBA and especially how to use it in an OO way. My intention is to create a base class "myClass" with common methods to use within my Excel application. These methods should be available in userForms and other modules (global scope).
Don’t know if it’s possible, but I would prefer to insatiate the class on "Workbook_Open" and then use the instance in other modules.
Example
myClass (Class Module)
ThisWorkbook
Module1
Is there a way of achieving this? The reason is that I don’t want to instantiate the class over and over again.
I’m new to VBA and especially how to use it in an OO way. My intention is to create a base class "myClass" with common methods to use within my Excel application. These methods should be available in userForms and other modules (global scope).
Don’t know if it’s possible, but I would prefer to insatiate the class on "Workbook_Open" and then use the instance in other modules.
Example
myClass (Class Module)
Code:
Public Sub Alert(Value As String)
MsgBox Value
End Sub
ThisWorkbook
Code:
Dim My As myClass
Public Sub Workbook_Open()
Set My = New myClass
End Sub
Module1
Code:
Sub Test()
My.Alert "Message"
End Sub
Is there a way of achieving this? The reason is that I don’t want to instantiate the class over and over again.