What Is An ActiveX Object?

An ActiveX object is an instance of a class that exposes properties, methods, and events to ActiveX clients. ActiveX objects support the COM. An ActiveX component is an application or library that is capable of creating one or more ActiveX objects. For example, Microsoft Excel exposes many objects that you can use to create new applications and programming tools. Within Microsoft Excel, objects are organized hierarchically, with an object named Application at the top of the hierarchy.

The following figure shows some of the objects in Microsoft Excel.

Each ActiveX object has its own unique member functions. When the member functions are exposed, it makes the object programmable by ActiveX clients. Three types of members for an object can be exposed:

For example, you might expose the following objects in a document-based application by implementing these methods and properties:

ActiveX object Methods Properties
Application Help
Quit
Save
Repeat
Undo
ActiveDocument
Application
Caption
DefaultFilePath
Documents
Height
Name
Parent
Path
Printers
StatusBar
Top
Value
Visible
Width
Document Activate
Close
NewWindow
Print
PrintPreview
RevertToSaved
Save
SaveAs
Application
Author
Comments
FullName
Keywords
Name
Parent
Path
ReadOnly
Saved
Subject
Title
Value

Often, an application works with several instances of an object which together make up a collection object. For example, an ActiveX application based on Microsoft Excel might have multiple workbooks. To provide an easy way to access and program the workbooks, Microsoft Excel exposes an object named Workbooks, which refers to all of the current Workbook objects. Workbooks is a collection object.

In the preceding figure, collection objects in Microsoft Excel are shaded. Collection objects let you work iteratively with the objects they manage. If an application is created with a multiple-document interface (MDI), it might expose a collection object named Documents with the methods and properties in the following table.

Collection object Methods Properties
Documents Add
Close
Item
Open
Application
Count
Parent