Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default How to use: ThisWorkbook module

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default How to use: ThisWorkbook module

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.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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.

Reply
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
Compile error in hidden module: ThisWorkbook Slibert New Users to Excel 2 May 19th 08 12:22 AM
Compile error in hidden module: ThisWorkbook Graeme Setting up and Configuration of Excel 3 April 4th 08 03:33 AM
Workbook_Open in ThisWorkbook.module Bob Barnes Excel Discussion (Misc queries) 1 February 12th 08 07:52 PM
Compile error in hidden module: ThisWorkbook Lloyd Excel Discussion (Misc queries) 1 May 27th 05 11:39 PM
ThisWorkbook module question Stuart[_5_] Excel Programming 3 July 17th 04 02:32 PM


All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"