Microsoft Office 2000/Visual Basic Programmer's Guide   

Programming Features

Each of the Office applications has been expanded to expose new objects, methods, and properties. To see complete object model diagrams for all the Office applications, as well as for components used by Office applications, see the Object Model Guide. For more information about how to work with objects, see Chapter 4, "Understanding Office Objects and Object Models." For additional information about working with the objects exposed by each Office application, see Chapter 5, "Working with Office Applications."

Expanded Event Model

The Office event model has been greatly expanded. Microsoft Word and Microsoft PowerPoint both expose more than two dozen new events, primarily associated with window and document objects. In addition, all Office applications now expose three command bar events:

For more information about command bar events, see Chapter 6, "Working with Shared Office Components."

New Language Elements

Several new functions are available to make it easier to format data or parse and manipulate strings. The following VBA functions can be used to format data: FormatCurrency, FormatDateTime, FormatNumber, and FormatPercent. You can use the Split, Join, and Filter functions to parse strings. The Split function parses a string into an array of substrings. The Join function is the opposite of the Split function: It creates a string from an array of substrings. Finally, the Filter function filters an array and returns an array containing the elements that match the specified criteria. You can also manipulate strings by using the new Replace and InStrRev functions. The Round function rounds a number to a specified number of decimal places. In this version of VBA, you can now write functions that return arrays and you can assign one array to another. For more information about using the new language elements, see Chapter 7, "Getting the Most Out of Visual Basic for Applications."

New Objects

Also new to VBA in Office are the FileSystemObject and Dictionary objects. The Dictionary object is analogous to a VBA collection, except that it can hold objects of different data types. The FileSystemObject object lets you work with the drives, directories, and files on your computer as if they were objects and collections of objects with methods and properties you can use to return information about your file system. For more information about using these new objects, see Chapter 7, "Getting the Most Out of Visual Basic for Applications."

The new objects and language elements make it even easier to work with objects exposed by Office applications and the shared Office components. But don't forget that VBA also gives you the ability to create your own objects. Also new to VBA in Office 2000 is the ability to add custom events to objects you create. In addition, you now have the ability to extend your custom objects by implementing interfaces. You can find a complete discussion of how to create and work with custom VBA objects in Chapter 9, "Custom Classes and Objects."