View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RichardG RichardG is offline
external usenet poster
 
Posts: 8
Default How to use: ThisWorkbook module

Thanks Jake,

Your explanation has been most helpful.

RichardG

"Jake Marx" wrote in message ...
Hi RichardG,

RichardG wrote:
In doing a word search on "ThisWorkbook" in this newsgroup's archives,
there was a lot of discussion on what to put into this module. What I
wanted to know is, what is the advantage of using this module verses a
general module or the worksheet module; and what is the purpose for
this module?


The ThisWorkbook module is a class module that contains the events
subroutines that are raised due to certain Workbook-related events. For
example, the Workbook_Open event routine will be executed when the Workbook
is opened. The Workbook_SheetActivate event routine will be executed when
the user (or code) activates a new Worksheet within the Workbook.

So, code related to the Workbook events should be placed in the ThisWorkbook
module. The various Worksheet modules are used for Worksheet-related events
(such as Change and SelectionChange), and standard modules should be used
for your VBA functions and subroutines.