View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using Events with the Application Object & XL 2003

See my answer to your later posting as new thread.

--
Regards,
Tom Ogilvy

"Kevin H. Stecyk" wrote in message
...
Hi Tom,

Let me put this in my own words to see if I have completely understood.

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.

Best regards,
Kevin

=================

Written by Tom Ogilvy....


ThisWorkbook is a class module, but it is already set up for you. You

only
need explicitly instantiate application level events if you want to have
events that are independent of the activities associated with an

individual
workbook or workhseet. In other words if I wanted to do something for any
workbook that is opened and I don't want to put the code in each workbook
then I would use application level events.

The common way show to instantiate application level events is with a

class
module, but KeepItCool pointed out that this could be done within the
thisworkbook module of workbook. Even if using a separate class module,

it
would still have to reside in a single workbook.

so your statement:

So you only need
to use the class modules for event handlers when you are working with
external workbooks.


Is accurate.

--
Regards,
Tom Ogilvy