Quote:
|
but if the workbook's name is another like "company". Can I change the "workbook" to "company"? And where do I put the code?
|
If I think I get what you're asking regarding the ThisWorkbook module. That is a static name and will be the same regardless of the workbook's actual name.
Workbook level events go into that module. I.E. Workbook_Open, Workbook_BeforeClose, Workbook_BeforePrint, etc. Event names are always the same (partially to keep you sane), so SmittysNewWorkbook_Open wouldn't do a damn thing, but Workbook_Open within Smitty's New Workbook would.
Worksheet level events go in the specific sheet modules, Worksheet_Activate, Worksheet_Deactivate. Both are Private Subs. ActiveX Control code is also stored in these modules. I.E. if you place a Control Toolbox Command Button in a worksheet, its code goes in that sheet's module.
General Subs, which can be called from anywhere in the workbook go in General Modules, which you place by going to Insert-->Module. Converse to ActiveX controls, Forms controls are assigned macros stored in General modules.
Clear as mud now?
Hope that helps,
Smitty