When you open the editor—either by clicking Tools, Macro, Visual Basic Editor, or by pressing Alt+F11—just two windows are visible:

• The Project Explorer shows all the modules, UserForms, and other items in your VBA project, including references to other projects.

Note Unless otherwise noted, in this chapter the term "project" means VBA project, whereas the term "plan" is used to refer to Microsoft Project files.

When you open the editor, two VBProject objects are listed. The first object, the ProjectGlobal project, contains all the code, UserForms, and modules associated with the Global file. The second object, the VBAProject project ("VBAProject" is the default name of any new project), contains the same items associated with the open Microsoft Project plan.

Initially, the This Project object is selected in the Project Explorer. This Project represents the plan itself, including events associated with the plan (see Figure 31-1).

Project - VBAProject



ll + ^ ProjectGlobal (Global.MPT)

B Çg Microsoft Project Objects

■^^■¿JEThisProject (31PrdDev.mpp)j

i"'Û Modules

E VBAProject (Projectl)

Figure 31-1. View all the items in your project by using the Project Explorer.

For more information about plan-level events, see "Working with Events" later in this chapter on page 919.

• The Properties window lists the properties for the selected item (see Figure 31-2). You can use the Properties window to easily change design-time properties, such as the name or style of an object, which can only be modified by using the editor.

Tip Run-time properties

Some of the properties listed in the Properties window are also run-time properties, which means they can be changed by your code while it is running.

Properties - ThisProject


l| ThisProject Project


| Alphabetic | Categorized ]

ThisProject *

AcceptNewExternalDal False AdministrativeProject False AllowTaskDelegation True AndMoveCompleted False AndMoveRemaining False AskForCompletedWork 1 - pjBrokenDownByC AutoAddResources True AutoCalcCosts True

AutoFilter False

AutoLinkTasks True

AutoSplitTasks True

AutoTrack True

CurrencyDigits 2


CurrencySymbolPositio 0 - pjEiefore ^

Figure 31-2. The Properties window shows the properties of the selected project and each of the items (UserForms, modules, and so on) that are contained in it.

Also of major importance is the Code window, in which you spend the majority of your time when using the editor. All Visual Basic code attached to a plan or a UserForm, or in a module or class, appears in the Code window. To open the Code window, simply double-click an item in the Project Explorer. (To view code for a UserForm, right-click and then click View Code.)

There are four controls associated with the Code window:

Objects box. For all items in the Project Explorer, this box displays the word (General). For VBProject objects and UserForms, it also displays the name of the object (Project or UserForm). Finally, for UserForms, the Objects box also displays the name of each control on the UserForm.



Procedures/Events box. For all items in the Project Explorer, this box displays the word (Declarations) and the names of procedures. For VBProject objects and UserForms, it also displays the names of events associated with the object selected in the Objects box.



Procedure View button. Displays just one procedure at a time in the Code window. This button is located in the lower-left corner of the Code window.

Full Module View button. Displays all procedures in the Code window, each separated by a horizontal line. Full Module is the default view for the Code window, and it is also located in the lower-left corner of the Code window.

The following windows are also part of the editor, but will be discussed in more detail later in this chapter:

Immediate. Any code entered in this window is immediately evaluated and run. Code entered in the Immediate window is not saved. It is frequently used as a sort of scratch pad, especially when debugging. Locals. Displays information about all local (procedure) variables and their values. Used when debugging.

Watch. Displays information about watches that have been created. A watch is any expression that can be evaluated to produce a value. Used when debugging. UserForm. Displays a UserForm. Used when creating or editing the visual elements of a UserForm.

Toolbox. Displays controls that can be placed on a UserForm, including ActiveX controls and other insertable objects you might have added to your project from external sources. Used when creating or editing the visual elements of a UserForm. Object Browser. Displays information about the objects, properties, methods, events, and constants (the object model) that are available in type libraries referenced by your project or that you create in procedures. (Type libraries are files with the .olb, .tlb, or .dll extensions.) Used when writing code or learning about the features of an object model.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment