LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Using Events with the Application Object & XL 2003

Hi,

I have never understood Class Modules very well. So please bear with as I
ask my questions.

My objective is to do the following:

1) Create a Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
2) In App_WorkbookOpen routine, I want to set a vba global variable.

I am not well versed with using event handlers.

So XL 2003 Help says,
~~~~
Before you can use events with the Application object, you must create a new
class module and declare an object of type Application with events. For
example, assume that a new class module is created and called
EventClassModule. The new class module contains the following code.

Public WithEvents App As Application
~~~~

I understand that.

Now it says,

~~~~
After the new object has been declared with events, it appears in the Object
drop-down list box in the class module, and you can write event procedures
for the new object. (When you select the new object in the Object box, the
valid events for that object are listed in the Procedure drop-down list
box.)

Before the procedures will run, however, you must connect the declared
object in the class module with the Application object. You can do this with
the following code from any module.

Dim X As New EventClassModule

Sub InitializeApp()
Set X.App = Application
End Sub

After you run the InitializeApp procedure, the App object in the class
module points to the Microsoft Excel Application object, and the event
procedures in the class module will run when the events occur.
~~~~

My understanding here is much weaker.

Once I have created the Private Sub App_WorkbookOpen(ByVal Wb As Workbook),
how do I get it to run? Does it not run automatically when the workbook is
opened? I am confused by the "Dim X as a New EvenClassModule" and the Sub
InitializeApp(). If you understand where my confusion lies, please clarify.

All I want to do at this point is set a global variable within the Private
Sub App_WorkbookOpen(ByVal Wb As Workbook) that can be changed by a "normal"
routine from within a normal (not class) vba module. What do I need to do?

Thank you.

Kevin






 
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
Application Events / App_WorkbookOpen Fries[_2_] Excel Programming 5 December 18th 04 01:21 PM
Application Level Events Question nickg420[_4_] Excel Programming 3 July 16th 04 05:02 PM
Application level events no longer execute R Avery Excel Programming 1 June 4th 04 01:21 AM
Using Application Events Thomas Herr Excel Programming 2 April 5th 04 09:24 PM
How-To - Forwarding Excel 2000 events to .Net application Joel Foner Excel Programming 0 January 28th 04 11:34 PM


All times are GMT +1. The time now is 10:22 AM.

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"