View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
OfficeUser OfficeUser is offline
external usenet poster
 
Posts: 12
Default What does it take to get class functions to execute?

I have an .ocx file named MyProject. It contains a class named MyClass which
contains two VBA functions:
Function MsgHello()
MsgBox "Hello World"
End Function

Function GoodByeWorld()
MsgBox "Good Bye World"
End Function

MyProject is referenced in Tools-References.

In the Sheet1 code module I have:
Public oMyClass As New MyProject.MyClass
on the Declarations section.

In the Sheet1 mudule I have this sub:
Private Sub Steve()
oMyClass.MsgHello
oMyClass.GoodByeWorld
End Sub

When I wrote the above code, when I typed oMyClass., intellisense popped up
a list containing MsgHelp and GoodByeWorld.

1. Should Sub Steve() be able to run in the Sheet1 module? If not, where
should I put the code?

2. When I try to run Sub Steve(), I get the errpr message "Invalid Use Of
New Keyword".

3. When I remove New from the line of code in the Declarations secyion, I
get the error message "Object Variable Or With Block Variable Not Set"

What does it take to get the functions, MsgHello and GoodByeWorld, to
execute?

Thanks!!!