Читать книгу Excel VBA Programming For Dummies - Dick Kusleika - Страница 51
Working with the Project Explorer
ОглавлениеIn the VBE, workbooks are called projects. Every workbook contains exactly one project, and every project is associated with exactly one workbook. A project holds all the modules and keeps them neatly in folders that tell you what kind of module it is. There are four kinds of modules, each kind in its own folder:
Microsoft Excel Objects: These are modules that are linked to user interface elements like workbooks and worksheets. See Chapter 11 for more about these types of modules.
Modules: Excel calls these simply modules, but everyone else refers to them as standard modules or VBA modules. These contain the code that doesn’t go in any of the other three module types.
Forms: These are modules that have a form user-interface. Chapter 16 provides an introduction to UserForms.
Class Modules: These are modules where you create your own objects. Class modules are beyond the scope of this book.
You can expand a project by clicking the plus sign (+) at the left of the project’s name in the Project Explorer. Collapse a project by clicking the minus sign (–) to the left of a project’s name. Or you can double-click a project’s name to expand and collapse it.
If a project is password-protected, the VBE prompts for its password when you double-click the project’s name. If you don’t know the password, you can’t expand the project — which means that you can’t view or modify any part of the project.
Figure 3-2 shows a Project Explorer with four projects listed: an add-in named UIHelpers.xlam, a workbook named Book1, a workbook named NumbersToWords.xlsm, and the Personal Macro Workbook (which is always named PERSONAL.XLSB). Of the four, only the NumbersToWords.xlsm project is expanded to show all of its modules.
FIGURE 3-2: This Project Explorer lists projects that can be expanded to show modules.
Every project expands to show at least one folder called Microsoft Excel Objects. This folder expands to show an item for each sheet in the workbook (each sheet is considered an object) and another object called ThisWorkbook (which represents the Workbook the module lives in). If the project has any VBA modules, the project listing also shows a Modules folder. And as you’ll find out in Part 4, a project may also contain a folder called Forms, which contains UserForm objects (that hold custom dialog boxes).
The concept of objects may be a bit fuzzy for you, but don’t worry. Things become much clearer in subsequent chapters. Don’t be too concerned if you don’t understand what’s going on at this point.