Assigning a Name to the VBA Project

A project is a set of Microsoft Excel objects, modules, forms, and references. Instead of the default name, VBAProject, that precedes the name of the workbook in the Project Explorer window, each project requires a unique name.

Let's assign names to VBAProject (Chap01.xls) and VBAProject (Personal.xls):

1. Start Microsoft Excel, and open Chap01.xls where your WhatsInACell macro code is stored. The Personal Macro Workbook where you recorded the FormulasOnOff macro will be automatically loaded.

2. Switch to the Visual Basic Editor window.

3. In the Project Explorer window, select VBAProject (Chap01.xls).

4. Double-click the (Name) property in the Properties window. This action selects the default project name VBAProject.

5. Type FirstSteps for the name of the VBA project, and press Enter. Notice that the Project Explorer window now displays FirstSteps (Chap01.xls) as the name of the VBA project.

6. In the Project Explorer window, select VBAProject (Personal.xls).

7. Double-click the (Name) property in the Properties window.

8. Type Personal for the name of the VBA project, and press Enter.

Tip 2-1: Avoid Naming Conflicts

To avoid naming conflicts between your VBA projects, give your projects unique names. You can change the name of the project in one of the following ways: ■ In the Project Explorer window, select the name of the project, double-click the (Name) property in the Properties window, and enter a new name.

■ In the Project Explorer window, right-click the name of the project, and select ProjectName Properties, where ProjectName is the name of the highlighted project. The Project Properties dialog box appears, as shown in Figure 2-1. Type the new project name in the Project Name text box.

VflAProject - Project Properties

m

General 1 Protection 1

project Name:

Project Description:

1

Project Help

Hetyj File Name:

Context ID:

1 1 ■« ■

Conditional Compilation Arguments:

1

on

Cancel | Help

The Project Properties window can be used for changing the name and description of the selected VBA project.

Figure 2-1:

The Project Properties window can be used for changing the name and description of the selected VBA project.

0 0

Post a comment