Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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!!! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't get that error.
oMyClass.MsgHello executes the function (Sub would be better?) Would you like to email me the .ocx file? And the .vbp and .cls and .ctl files if you have them? dacromley @ wyoming . com "OfficeUser" wrote: 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!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel functions do not execute | Excel Worksheet Functions | |||
Execute class method on all worksheets? | Excel Programming | |||
Class modules: parametrize class object fields | Excel Programming | |||
Passing Custom Class Variables through Functions | Excel Programming | |||
class functions | Excel Programming |