ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What type of code do you put in "ThisWorkBook"??? (https://www.excelbanter.com/excel-programming/348695-what-type-code-do-you-put-thisworkbook.html)

Hexman

What type of code do you put in "ThisWorkBook"???
 
I assume any public code that is common to the entire workbook. Isn't
"ThisWorkBook" just the same as a user-added module?

Please set me straight on the use of "ThisWorkBook" vs Modules.

Thanks,

Hexman


Bob Phillips[_6_]

What type of code do you put in "ThisWorkBook"???
 
ThisWorkbook is a class module, specific to workbook events, such as
Workbook_Open. There are also worksheet class modules, where worksheet
events are invoked. Code in these modules is usually not accessible from
other modules, neither other class modules nor standard code modules.

Unlike standard code modules, which have to be explicitly added to a
workbook, these class modules automatically get created when a workbook is
created, and when sheets are created.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hexman" wrote in message
...
I assume any public code that is common to the entire workbook. Isn't
"ThisWorkBook" just the same as a user-added module?

Please set me straight on the use of "ThisWorkBook" vs Modules.

Thanks,

Hexman




Hexman

What type of code do you put in "ThisWorkBook"???
 
On Thu, 22 Dec 2005 00:50:30 -0000, "Bob Phillips"
wrote:

ThisWorkbook is a class module, specific to workbook events, such as
Workbook_Open. There are also worksheet class modules, where worksheet
events are invoked. Code in these modules is usually not accessible from
other modules, neither other class modules nor standard code modules.

Unlike standard code modules, which have to be explicitly added to a
workbook, these class modules automatically get created when a workbook is
created, and when sheets are created.


Thanks for the explanation.

Hexman

42N83W

What type of code do you put in "ThisWorkBook"???
 

"Hexman" wrote in message
...
I assume any public code that is common to the entire workbook. Isn't
"ThisWorkBook" just the same as a user-added module?

Please set me straight on the use of "ThisWorkBook" vs Modules.

Thanks,

Hexman


The ThisWorkbook code module is a good place to put menu creation and
deletion code and variable initiation code. If you put code like this in
the ThisWorkbook code module for your PERSONAL.XLS file, you can load all
sorts of customizations and menus when the app starts. The only two events
in this module that I currently utilize are the Workbook_Open event the
Workbook_Close event.



Hexman

What type of code do you put in "ThisWorkBook"???
 
On Wed, 21 Dec 2005 19:46:39 -0600, "42N83W"
wrote:


"Hexman" wrote in message
.. .
I assume any public code that is common to the entire workbook. Isn't
"ThisWorkBook" just the same as a user-added module?

Please set me straight on the use of "ThisWorkBook" vs Modules.

Thanks,

Hexman


The ThisWorkbook code module is a good place to put menu creation and
deletion code and variable initiation code. If you put code like this in
the ThisWorkbook code module for your PERSONAL.XLS file, you can load all
sorts of customizations and menus when the app starts. The only two events
in this module that I currently utilize are the Workbook_Open event the
Workbook_Close event.

Thanks,

Hexman


All times are GMT +1. The time now is 02:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com