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

  • Thread starter Thread starter Hexman
  • Start date Start date
H

Hexman

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
 
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)
 
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
 
Hexman said:
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.
 
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
 

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

Back
Top