Custom Classes and ObjectsThis content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Are you ready to take your Microsoft® Visual Basic® for Applications (VBA) programming skills to a new level? If you have never used class modules to build custom objects before, this section covers the concepts that you must understand to design, build, and use custom objects with their own methods and properties. If you have been building your own objects for some time now, this section also covers some exciting new additions to the VBA language in Microsoft® Office XP: the ability to add custom events to your objects, and the ability to extend your objects by implementing interfaces. In addition to describing how to use VBA to build custom objects, this section introduces the basics of using script to create reusable custom objects for Web pages.
In This Section
- Why Build Your Own Objects?
- Build entire custom object models that involve complex code behind the scenes, but that present a relatively simple and intuitive object syntax to the programmer.
- Basic Class Concepts
- Become familiar with using class modules to build custom objects, and learn the basics of adding a class to your project, creating an instance of a class in memory, and constructing properties and methods.
- Creating Property Procedures
- Public module-level variables in a class module function as properties of an object.
- Creating Events and Event Procedures
- Take advantage of simple to create events procedures and use ThisDocument, ThisWorkbook, or SheetN objects.
- Extending Objects Through Interfaces
- Suppose that in the process of designing your application, you decide that you want to create several objects that are closely related, and, in fact, require at least some of the same properties and methods.
- Designing Object Models
- When you design an object model, you are taking abstract processes and imposing concrete relationships upon them.
- Creating Custom Objects for Web Pages
- There are two ways to create objects for Web pages that are similar to custom objects created in VBA — by creating scriptlets and by using Microsoft® Internet Explorer version 5 and later behaviors.
- Programming Concepts
- When you program, you store data and manipulate it with a series of instructions. The data and data storage containers are the raw materials of programming.
- Writing Solid Code
- "Writing solid code" means writing Microsoft® Visual Basic® for Applications (VBA) code or script that performs as expected and is reusable, easy to understand, and easy to maintain.
- The Windows API and Other Dynamic-Link Libraries
- One of the most powerful features of Microsoft® Visual Basic® for Applications (VBA) is its extensibility. You can extend your applications by calling functions in the Microsoft® Windows® application programming interface (API) and other dynamic-link libraries (DLLs).