Using the Visual Basic Editor

The Visual Basic editor — where you write, edit, and test your VBA code — contains lots of optional tools and panes. There are so many of them, in fact, that I can't even tell you exactly how the editor will look on your screen the first time you open it. However, it will likely contain at least some of the components in Figure 2-1.

Like most program windows, the Visual Basic editor has a title bar and menu bar at the top. Optional toolbars appear under the menu bar. You can hide or show any toolbar at any time. Choose ViewOToolbars from the menu bar, and then select the check box of the toolbar you want to show or hide.

Figure 2-1:

Some of the VBE optional panes.

Figure 2-1:

Some of the VBE optional panes.

Standard toolbar

Properties window Immediate window Code window Project Explorer

Standard toolbar

The View menu also provides options for making the various panes shown in Figure 2-1 visible. For example, if the Immediate window isn't visible, choosing ViewOImmediate Window from the menu bar makes it show. To close an open pane or window inside the VBA editor, click the Close (X) button in the upper-right corner of the pane that you want to close.

In Figure 2-1, the optional panes are currently docked (attached) to the VBA editor program window. You can undock any pane and change it to a freefloating window. Just drag the item's title bar toward the center of the program window and release the mouse button. For example, Figure 2-2 shows the Project Explorer pane still docked and the Properties window undocked. The title bar for each item is also pointed out in the figure.

If you undock an item, you can generally re-dock it by dragging it back to any edge of the VBA editor program window. If the item refuses to dock, try right-clicking within the item and choosing Dockable from the contextual menu that appears. Then drag the item to an edge or border if it doesn't dock right on the spot.

Figure 2-2:

Examples of docked and undocked panes.

Docked Title bars

Undocked

Figure 2-2:

Examples of docked and undocked panes.

Docked Title bars

Undocked

You can size any pane (or free-floating window) by dragging any edge of the item. For example, when both the Project Explorer and Properties panes are docked, you can widen or narrow them both by dragging the right edge of the pane. Drag the bottom edge of a pane to make it taller or shorter.

Whether you really need all the panes open depends on what you're doing at the moment within the VBA editor. You'll probably spend the vast majority of your time in the Code window. Before I discuss that window, take a quick look at the optional Project Explorer and Properties window.

0 0

Post a comment