Automate Complex Tasks

Previous Topic

Previous Page
Next Topic

Next Page

Recorded macros are great when you want to perform exactly the same task every time you run the macro. But what if you want to automate a task in which the actions vary with the situation, or depend on user input, or move data from one Office application to another? For example, you might want to assign a background color to a worksheet cell based on the day of the week that data is entered into the cell, display the performance review form for the employee whose name you enter, or automatically link the most recently created Microsoft Excel chart in your My Documents folder to a PowerPoint slide.

To create automations that are more powerful than recorded macros, you should learn to program in Visual Basic for Applications. If you’ve never programmed before, don’t be scared off! Learning Visual Basic for Applications can be much easier than learning other programming languages, because many of the commands in Visual Basic for Applications are named after familiar interface features, such as dialog box options. A good way to see this is to look at the instructions in a macro you’ve recorded. Chances are, you’ll recognize many of the words and will be able to figure out what some of the instructions mean without knowing anything about programming. For information on displaying a recorded macro, look up Getting Results - Automate in Help.

Learning Visual Basic for Applications is well worth the time investment. Many companies are finding that they can use it to extend the features of Office rather than buying dedicated software packages for each task they want to automate. Custom solutions can take less time to develop, since the developer can take advantage of all the features that are built in to Office applications. Creating a custom tool in Visual Basic for Applications can also decrease the amount of training and support employees need in order to use a new tool, since the tool is based on an application they’re already familiar with.

You can learn more about Visual Basic for Applications at your own pace. If you like to learn by experimenting, try looking at the code for some of your recorded macros, and then refer to the online reference topics to find out more about specific programming words. (To display a reference topic, place the insertion point in a keyword in the code editing window and then press F1.) If you prefer a more structured approach, try one of the books in the Microsoft Press Step-by-Step series. For more information, see Microsoft Press Publications for Microsoft Office 97.