D
Donald Nova
I'm trying to get started with Classes, I understand the concepts but I just
cannot seem to get them to work. Here is some very basic demo code to
highlight the problems I'm getting:
=====================
' Code attached to ThisDocument
Public Sub AutoOpen()
Dim c1 As New Class1
Dim c2 As New Class2
c1.SayHello
End Sub
=====================
=====================
' Code attached to Class1
Public Sub SayHello()
Debug.Print "Class1 says hello"
c2.SayHelloAlso
End Sub
=====================
=====================
' Code attached to Class2
Public Sub SayHelloAlso()
Debug.Print "Class2 also says hello"
End Sub
=====================
When Run, I get a error dialog box stating "Object required".
Now I am sure the problem is because the initialisation of the classes are
only temporary within the AutoOpen() procedure, however I'm not entirely
sure how to make the classes persistant and permanantly accessable by other
classes and functions?
This has been driving me mad!!
Cheers
Donald
cannot seem to get them to work. Here is some very basic demo code to
highlight the problems I'm getting:
=====================
' Code attached to ThisDocument
Public Sub AutoOpen()
Dim c1 As New Class1
Dim c2 As New Class2
c1.SayHello
End Sub
=====================
=====================
' Code attached to Class1
Public Sub SayHello()
Debug.Print "Class1 says hello"
c2.SayHelloAlso
End Sub
=====================
=====================
' Code attached to Class2
Public Sub SayHelloAlso()
Debug.Print "Class2 also says hello"
End Sub
=====================
When Run, I get a error dialog box stating "Object required".
Now I am sure the problem is because the initialisation of the classes are
only temporary within the AutoOpen() procedure, however I'm not entirely
sure how to make the classes persistant and permanantly accessable by other
classes and functions?
This has been driving me mad!!
Cheers
Donald