5.1. VBA Objects

You can't program in VBA without understanding how the various VBA components work together. All VBA code is comprised of individual statements. Those statements take objects and manipulate their properties, call their methods, and perform their events. This section introduces the concepts of objects, properties, methods, and events.

VBA is an object-oriented programming (OOP) language. OOP is a type of programming in which programmers define a complete data structure from data types to the operations that can be applied to the data structure. Programmers can create an entire object that contains both data and the operations that the object can perform. They can also create relationships between objects.

There are seemingly countless objects that you can work with using VBA. The collection of objects exposed by a particular application is called an object library. You can incorporate multiple object libraries in VBA. For example, you can use VBA to manipulate the Access object library and work with objects such as tables, queries, forms, and reports. You can set references to other object libraries such as Microsoft Outlook, Adobe Acrobat, or Microsoft Word. (Appendix B provides an in-depth discussion of how to set and use references.) Every time you set a reference to another application's object library, you have access to all objects within that library. An object is generally thought of as a physical thing. For example, if you were to set a reference to a ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.