Working with Objects

What Is an Object? 71

The Object Hierarchy 73

Working with Object Properties 73

Working with Object Methods 75

Handling Object Events 77

Working with Object Collections 78

Assigning an Object to a Variable 79

The Is Operator 80

Working with Multiple Properties or Methods 80

Example:The Application Object 81

Example:The Window Object 88

Many of your VBA procedures will perform calculations using simple combinations of numbers, operators, and the host application's built-in functions. You'll probably find, however, that most of your code manipulates the application environment in some way, whether it's formatting document text, entering data in a worksheet range, or setting application options. Each of these items—the document, the range, the application—is called an object in VBA. Objects are perhaps the most crucial concept in VBA programming, and I'll explain them in detail in this chapter.

0 0

Post a comment