How to use: ThisWorkbook module

R

RichardG

Greetings All,

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?

Many thanks in advance.

RichardG
 
J

Jake Marx

Hi RichardG,
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.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top