Automation has a ways been the great promise of the computer age-get more work done or lounge in your recliner as the computer toils away as repetitive tasks. In order to have your computer perform a series of actions at the click of a button, you need to tell the computer what to do in words that it understands. What if your company has a need for a specialized contact sheet, wants to speed up the budget approval system, or wishes to collect disparate versions of a Word document and create a report on the changes as quickly as possible? Clippit is cool, but you can’t simply tell your computer to “go do” these things, as you would tell a human assistant. You need to write a program.
This’ is where Visual Basic and Visual Basic for Applications (VBA)come in. Computers are perfectly literal, so when writing a program, you have to tell the computer exactly what to do, where to find things, and what to do if something unexpected happens.
Microsoft has worked hard to make programming with VBand VBA relatively easy, using English language terms strung together to tell your computer what to do. If you’ve programmed in the past, you should find Visual Basic fairly easy to learn. If you haven’t programmed before, the learning curve will be a little steeper because you also have to learn to think like a computer. But the hardest part about using VB to automate Project 2000 is learning Project 2000, not learning VB. If you’re working in this chapter, chances are you already have Project 2000 under your belt.
In the next two chapters, we will discuss Visual Basic and its offspring, VBA There is yet an other child of Visual Basic, called VB Script, that is used in Microsoft Outlook and is fine-tuned for Internet and communication tasks, but that’s a different application!
What Is Visual Basic?
To understand what VB is, we need to understand what it does. Within the scope of its capabilities, VB performs the tasks you request. used to tell your computer to tape tonight’s WNBA game unless your computer is actually capable of controlling a video-recording device. If it can, taping tonight’s game is ~ slam-dunk with VB.
However, you will probably not be seeking video recording help from VB. You’ll use the application-based version of VB, VBA,to automate tasks and extend the capabilities of Project 2000. Project is an accomplished assistant for a number of project manage~ent tasks, but Microsoft realized that there was no way it could anticipate the exact needs of all its users, so it enabled you to enhance Project 2000 by using programming code and forms
Introducing the Integrated Development Enviroment
When you add a resource, record progress on a task, or map data for import, you are using a form. As shown in Chapter 23, “Customizing Fields and Forms, n you can use the Microsoft Form Editor to create and modify Project’s custom forms. Working in the Visual Basic Integrated Development Environment to create code or a form is not much different from creating a Project custom form–except that the IDE is more powerful and easier to use than the Custom Form Editor! As you’ll see, the “visual” part of Visual Basic comes. from the fact that most of the code is generated by drawing the controls onto a virtual canvas, the aforementioned forms. To open the VBAIDE, start up your computer and follow these steps
1. Open Project and select Tools> Macro> Visual Basic Editor. You can also open this window by holding AIt and pressing F11. The Visual Basic environment is displayed. If this is the first time you’ve opened tIle IDE, it’s a blank sheet. Now, w.e will open the windows we need to begin working in the IDE.
2. Select View> Project Explorer. The Project Explorer window is displayed. This window is used like the Windows Explorer to select the project and the Objects, Forms, or Modules with which to work.
3. Select View> Properties Window. The Properties window contains the properties for the selected object. If you have worked with Microsoft Access, you already have experience with Properties Windows. If not, browse through the properties for your currently active project and you will see that display, prioritization, and function defaults are defined in this window: Changes you might have made to your project defaults will appear in the Properties window
You now have a large blank area in which to work, and two open windows, Project Explorer and Properties, with which to begin. This pristine fDE is shown in Figure 24.1.