Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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!!!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default What does it take to get class functions to execute?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel functions do not execute Bill Excel Worksheet Functions 4 September 21st 08 10:06 PM
Execute class method on all worksheets? Nik[_4_] Excel Programming 4 April 1st 07 10:34 PM
Class modules: parametrize class object fields Jean-Pierre Bidon Excel Programming 11 August 31st 06 02:49 PM
Passing Custom Class Variables through Functions Xiazer[_13_] Excel Programming 2 May 19th 06 05:34 PM
class functions TheIrishThug[_16_] Excel Programming 3 December 31st 05 04:16 PM


All times are GMT +1. The time now is 10:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"