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 Further Clarification with Event Handlers & Class Modules

Hi,

This post is a continuation from a prior post on the same topic.

http://tinyurl.com/6a8wd

My prior post was as follows:

1) You need class modules for event handlers.

2) ThisWorkbook is a class module. It is "already set up for you" in the
sense that you don't need to instantiate it. That's already set up. The
Workbook_Open event, for example, is already instantiated. (Question, are
any and all event handlers placed in ThisWorkbook class module
pre-instantiated? Could you place ALL your event handler for the current
and external workbooks in ThisWorkbook class module?)

3) ThisWorkbook class module is used for current workbook events.
(Question, can you place other event handlers in ThisWorkbook class module
that are used for external workbooks? I am guessing NO. But I want to be
clear in my understanding.)

4) You can create your own class modules. When dealing with external
workbooks, event handlers are usually created in a separate class modules
outside of ThisWorkbook class module. You can rename your class modules to
suit your purpose. But these class modules remain void until they are
instantiated by another event handler within ThisWorkbook class module.
Once they are instantiated, they become active.

Thank you Tom for walking me through this material.

Question 5)

My last question concerns Chip's notes on his site:

http://www.cpearson.com/excel/AppEvent.htm

Quoting:

~~~~~~~~~~~
Enter the following code in the Workbook_Open event procedure for your
workbook:

Set AppClass.App = Application

If desired, you can move the code to initialize the App object to the
Initialize event of the class itself. This event is automatically executed
when a new object based on the class module is created. There is also a
corresponding Terminate event.

Private Sub Class_Initialize()
Set App = Application
End Sub


If you use this technique, you can remove the following line of code from
your Workbook_Open event procedure.

Set AppClass.App = Application

Now, your workbook is ready to process application level events.
~~~~~~~~~~~~~

I understand how the Workbook_Open instantiates the class module. But I am
less clear on the "initialize" event. Can someone please elaborate on how
the two differ and why you would use one form over another.

This should be my last set of questions on this topic for a while. I should
have sufficient information to go and experiment and discover on my own for
a while.

I know I have asked a lot of questions regarding event handlers and class
modules. I never understood this topic very well, so I wanted to take this
opportunity to try to better understand this topic. I am appreciative of
everyone's assistance.

Thank you.

Best regards,
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
Grouping Event handlers Ripan[_4_] Excel Programming 4 February 7th 04 02:40 PM
Class Modules ibeetb Excel Programming 1 January 5th 04 10:04 PM
Problems with event handlers Italian Job Excel Programming 2 November 12th 03 01:26 AM
Class Modules vs Modules Jeff Marshall Excel Programming 2 September 28th 03 07:57 PM
Event - RaiseEvents Within Class Modules John Peterson[_3_] Excel Programming 4 July 17th 03 12:53 AM


All times are GMT +1. The time now is 10:03 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"