Working with the Project Explorer

Vertex42 The Excel Nexus

Professional Excel Templates

Get Instant Access

When you're working in the VBE, each Excel workbook and add-in that's currently open is considered a project. You can think of a project as a collection of objects arranged as an expandable tree. You can expand a project by clicking the plus sign (+) at the left of the project's name in the Project Explorer window. You contract a project by clicking the minus sign (-) to the left of a project's name. If you try to expand a project that's protected with a password, you are prompted to enter the password.

Note The top of the Project Explorer window contains three icons. The third icon, named Toggle Folder, controls whether the objects in a project are displayed in a hierarchy or are shown in a single non-hierarchical list.

Figure 7-3 shows a Project Explorer window with three projects listed (one add-in and two workbooks).

Pmjpct - VEAProject

+ Q fcicowft Excel Objects - {fs Fffms

¡n Far in About fe a MocJes


- AS. VSAPrgjetUBotikl)

= fciorKsfc Esee) Objects fflfl SwtL (Shwlrl) TtnslVofttwoi;

- ^ VBAProjti:t (ixlrndtrd rl<ili' fiirn tiarmfkui)

= (Si Microsoft E»ct) Objects B1) Sheetl (EhcctlJ £ ThrtVoriiwt S ¿3 ModJis mil Module 1

Figure 7-3: A Project Explorer window with three projects listed.

Caution When you activate the VBE, you cannot 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.

Was this article helpful?

0 0

Post a comment