Why Use Visual Basic Macros?

 <  Day Day Up  >  

There are several reasons you might want to use Visual Basic to create macros. This chapter covers some of the most common reasons and gives examples so that you can start creating your own.

Macros were originally used to collect a series of keystrokes that performed a given command or series of commands so that you could run the macro instead of typing the string of commands. This is very useful when the work you are doing is repetitive, such as setting a particular format or printing a particular report. This original functionality evolved and now, instead of just recording and replaying keystrokes, macros can do much more. Microsoft includes Visual Basic for Applications (VBA), a fully functional programming language, in Project as well as other Microsoft Office products. Having a programming language rather than a macro language allows you to program Project to do things that cannot be done by using simple macro functionality. It also allows you to have Project work with other Office applications to achieve the result you want. For example, using VBA, you can have Project send data to Excel and because Excel also uses VBA, you can tell Excel to chart the data in a specific way.

There are four basic ways to use VBA in Project:

  • Automation ” Many activities in Project require that you perform a number of separate actions in a distinct order. Printing a customized report is a good example of this. You need to select the report type, set the options the way you like, and print. This requires navigating through several menus and dialog boxes, making a variety of choices as you go. Because you typically want reports to be in the same format for each reporting period, this process can be automated so that you don't have to go through those steps individually each time you want to print a report. When the process is automated, the formatting of the printed reports is the same each time.

  • Configuration ” Configuration of Project is another good use for VBA. You can use VBA to configure the toolbars , views, and other customizable elements of Project so that you can always have it set up the way you like. You can also use VBA to create a common configuration that you can distribute to a group of users.

  • Interrelationships ” VBA enables Project to work with other software tools. VBA enables you to open and control other applications, and it enables Project to be controlled by other applications as well. Project and Excel are often used together, to take advantage of the graphing and analysis capabilities of Excel.

  • Extended functionality ” You can use VBA to extend the functionality of Project. Although Project is packed full of functions, there are some things it just does not do. With complete access to the Project object model, via VBA, you can add functionality to Project. Simple things such as automatically renaming a group of tasks and complex things such as tracing the dependencies to a selected task are all possible with the use of VBA.

This chapter covers a very simple example of recording a macro as an introduction to the concepts and definitions related to VBA, and then it moves on to the Project object model and some typical programming structures that you can adapt for whatever you need to develop.

 <  Day Day Up  >  


Special Edition Using Microsoft Office Project 2003
Special Edition Using Microsoft Office Project 2003
ISBN: 0789730723
EAN: 2147483647
Year: 2004
Pages: 283
Authors: Tim Pyron

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net