Accessing Linked and Embedded Objects

Some applications that supply objects support linking and embedding as well as Automation. Using the ActiveX control (Msole2.vbx) from the OLE toolkit, you can create and display embedded objects in a Visual Basic application. If the objects also support Automation, you can access their properties and methods by using the Object property. The Object property returns the object in the ActiveX control. This property refers to an ActiveX object in the same way an object variable created with the functions New, CreateObject, or GetObject refers to the object.

For example, an ActiveX control named Ole1 contains an object that supports Automation. This object has an Insert method, a Select method, and a Bold property. In this case, the following code could be written to manipulate the ActiveX control's object:

' Insert text in the object.
Ole1.Object.Insert "Hello, world."
' Select the text.
Ole1.Object.Select
' Format the text as bold.
Ole1.Object.Bold = True