Accessing Automation Object Members

See Also

The MDO Model contains a number of Automation objects that support multiple interfaces. With each Automation object, one interface is defined to be the default interface, and the members (the properties, methods, and collections) that are attached to that interface are accessible via the standard Visual Basic mechanisms.

When accessing members that are attached to an interface that is not the default interface for an Automation object, a different access technique must be used. An additional reference to the object must be declared that explicitly calls for the non-default interface. The non-default interface members can then be accessed via the new object reference.

The following example illustrates how to access a collection that is attached to an interface that is not the default interface for an Automation object.

In this example, the repository object that represents the first control in a Visual Basic form is retrieved. MdoVBForm objects implement the IMdoControlContainer interface; this interface is not the default interface. The MdoControls collection is attached to the IMdoControlContainer interface. The MdoControls collection is the collection of controls that are contained in the form.

Dim vbFormObj    As MdoVBForm
Dim nonDefIfcObj As IMdoControlContainer
Dim controlObj   As MdoControl

'  Initialize the vbFormObj object by retrieving it
'  from the collection of components that are part
'  of a particular Visual Basic project.

Set nonDefIfcObj = vbFormObj
Set controlObj = nonDefIntObj.MdoControls(1)