Microsoft Office Tutorials and References
In Depth Information
Working with the Project Explorer
Figure 7-3: A Project Explorer window with four projects listed.
When you activate the VBE, you can’t assume that the code module that’s displayed
corresponds to the highlighted object in the Project Explorer window. To make sure
that you’re working in the correct code module, always double-click the object in the
Project Explorer window.
If you have many workbooks and add-ins loaded, the Project Explorer window can be a bit
overwhelming. Unfortunately, you can’t hide projects in the Project Explorer window. However, you
probably want to keep the project outlines contracted if you’re not working on them.
When viewing the Project Explorer in folder view, every project expands to show at least one
node called Microsoft Excel Objects. This node expands to show an item for each worksheet and
chart sheet in the workbook (each sheet is considered an object) and another object called
ThisWorkbook (which represents the Workbook object). If the project has any VBA modules,
the project listing also shows a Modules node, and the modules are listed there. A project can
also contain a node called Forms that contains UserForm objects (also known as custom dialog
boxes). If your project has any class modules, it displays another node called Class Modules.
Similarly, if your project has any references, you see another node called References. The
References node is a bit misleading because references can’t contain any VBA code.
Adding a new VBA module
To add a new VBA module to a project, select the project’s name in the Project Explorer window
and choose Insert➜Module. Or you can just right-click the project’s name and choose
Insert➜Module from the shortcut menu.
When you record a macro, Excel automatically inserts a VBA module to hold the recorded code.
 
Search JabSto ::




Custom Search