Getting Started with the Project Explorer

Woman riding a kayak in the middle of a lake - Photo by Kalen Emsley on Unsplash
Photo by Kalen Emsley on Unsplash
To master Excel VBA you'll have to get comfy in its coding dojo, the VBA Editor. Here, you'll explore its essential navigation tool, the Project Explorer.

In this article:

8 minutes read

This article is part of the Visual Tour of Excel’s Coding Dojo series, exploring each of the Excel VBA Editor’s menus, toolbars, and windows. Here, we’ll take a close look at the Excel VBA editor’s Project Explorer.

“I haven’t been everywhere, but it’s on my list.”

Susan Sontag

If you wish to skip to any of the other posts in the series, click on any of the topics listed below:

Meet your Mat! The VBA Editor

Most great martial artists first had to get intimate with their dojo. Likewise, to master Excel VBA, you’ll have to get comfy loitering in its coding dojo, the VBA Editor. Naturally, the first step is to open the VBA editor.

“The Dojo is the only place you can die and come back to life, so use it.”

kyoshi Larry Mabson (American karateka)

I, for one, know how daunting the Excel VBA editor can appear to beginners – just take a look at the overview below! However, looks can be deceiving; at least that’s true here. I say that because anyone familiar with programming IDEs will tell you that the VBA editor is one of the more user-friendly IDEs out there.

IDE stands for Integrated Development Environment. They are software that consolidates application development tools.

Laying out the different areas and windows of the Excel VBA Editor (VBE)
Laying out the different areas and windows of the Excel VBA Editor (VBE)

Most developers only use a few of the VBA Editor’s menus, toolbars, and windows. As a result, they miss out on several tools that would make their work less stressful and enhance their productivity.

But you are not most developers, are you? For one thing, you are here, so I take it you would like to max out your VBA programming potential. Brilliant! You are well on your way there.

Project Explorer – Overview

The Project Explorer (or Project window) opens at the top left of the VBA Editor, below the Menu bar by default. Though there are several uses for the Project Explorer, the foremost is navigating in your VBA projects.

To display the Project Explorer, you select it from the View menu or click its icon on the Standard toolbar, or press “Ctrl + R” (see the image below). Also, you can show the Project Explorer by pressing the “Alt + V + P” key combination.

Illustrating multiple ways of displaying the Project Explorer
Illustrating multiple ways of displaying the Project Explorer

The Project Explorer is an outline of all currently open workbooks and enabled add-ins, each being a separate project. The explorer’s outline is hierarchical by default (i.e., Folder view). However, you can toggle its view to a non-hierarchical one (i.e., Contents view).

Project Explorer’s hierarchical or Folder view (on the right) and non-hierarchical or Contents view (on the left)
Project Explorer’s hierarchical or Folder view (on the right) and non-hierarchical or Contents view (on the left)

In either view, the outline shows in tree-view. Projects (i.e., workbooks or add-ins) are the roots of the tree. While the project’s VBA objects or modules (i.e., code containers) as nodes.

A module is a program component that comprises one or more procedures. In VBA, there are Standard and Class modules; these are explained later in this article.

Project Explorer – Buttons

The image below shows the Project Explorer’s buttons. The following highlights some crucial aspects of these buttons:

  • The View Code button displays the selected node’s code script (i.e., any code linked to the node) in the Code window. The node may be a module or an object.
  • Depending on the selected object, the View Object button displays either its UserForm in the Code window or the object itself in Excel’s window. The first case happens when the object is a UserForm, while the second case occurs when a viewable object (e.g., Sheet or ThisWorkbook) is selected. Note, UserForms are graphical interfaces designed by developers for user interaction with applications.
  • The aptly named Toggle Folders button toggles the explorer between views. The available views are the Folder (hierarchical) and Contents (non-hierarchical) views.
  • The Toolbar Options button allows the addition or removal of buttons. However, this functionality is disabled in the Project Explorer.
Project Explorer buttons to view code or objects, collapse or expand folders, access Toolbar Options, and close the explorer
Project Explorer buttons to view code or objects, collapse or expand folders, access Toolbar Options, and close the explorer

A procedure is a code block, that performs certain tasks and may return a value once executed. In VBA, it is written between a Sub (or Function) and an End Sub (or End Function) statement.

Project Explorer – Views and Content

The Contents view shows the project’s root and nodes. However, the Folder view shows intermediate roots (folder levels). These folders are placeholders for collections of similar Excel VBA objects and modules.

Further, all VBA projects consist of a combination of such folders. The following describes each of these common folder types:

  • Microsoft Excel Objects – contain the project’s objects and their associated procedures. In particular, it comprises the ThisWorkbook and Sheet (note, one for each worksheet) objects. By holding objects’ code modules, it allows access to their properties (i.e., attributes), events (i.e., action-triggers), and methods (i.e., actions).
  • Forms – contain the project’s UserForms, which exist to enhance user interaction (i.e., input or output) with the application.
  • Standard Modules – contain the project’s object-independent procedures. These procedures can either subroutines or functions. Both procedure types perform a specific task (which may have sub-levels), but only functions return a value once done. Note, these procedures differ from the object-dependent or object-associated procedures in the Microsoft Excel objects folder.
  • Class Modules – contain the project’s standalone code modules designed to create new VBA objects. Class modules define the properties and methods of custom objects.
  • References – contain the project’s references to external resources, e.g., dynamic link libraries.

Statements are one-liner instructions, written in a programming language, directing computers to execute specific tasks. In Excel VBA, these are source code commands instructing Excel’s virtual machine to perform a specific task.

Double-clicking a node in the Project Explorer displays either its UserForm or code script in the Code window. The first case happens when the node is a UserForm, while the second case occurs otherwise. Also, right-clicking a node or any area of the Project Explorer displays a Context menu listing quick actions, as shown in the image below.

Context Menu displayed by right-clicking anywhere in the Project Explorer
Context Menu displayed by right-clicking anywhere in the Project Explorer

Project Explorer – Uses

The Context menu indicates some of the other uses of the Project Explorer, besides project navigation. It shows that the explorer also helps with:

  • Importing, exporting, adding, and removal of modules and UserForms;
  • Moving or copying of modules and UserForms between projects. To do this, using your mouse, drag the module or UserForm from one project to the other;
  • Dragging of modules and UserForms between projects in different Office applications. However, for you to do this, both applications must support the module or UserForm type.

The Long and Short of It

You now know all there is to know about the VBA editor’s Project Explorer (a.k.a., the Project window). Primarily, the Project Explorer facilitates navigation between different elements of your VBA projects. Also, if it isn’t displayed by default in your VBA editor, you can select it from the View menu or click its icon on the Standard toolbar, or press “Ctrl + R” or “Alt + V + P” keyboard shortcuts.

Moreover, you’ve breezed through the Project Explorer’s buttons and its different views (Contents and Folder views). Also, you’re now familiar with the various folders you can access from the explorer as well as its other uses besides project navigation.

You can also check out the Office Dev Center page for more info on the VBA editor’s Project window.

As I mentioned earlier, this article is part of the Visual Tour of Excel’s Coding Dojo series exploring each of the Excel VBA Editor’s menus, toolbars, and windows. To check out any of the other posts in the series, click on topic links below:

4.5 2 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Keep Learning

Related Articles

Keep Learning

Related Articles