Object Property

Applies To

Bound Object Frame Control, Chart Control, Unbound Object Frame Control.

Description

You can use the Object property in Visual Basic to specify a linked or embedded OLE Automation object in a control.

Setting

The Object property setting is a Object data type value that specifies an OLE Automation object used in OLE Automation tasks.

The Object property setting is read-only in all views.

Remarks

You perform OLE Automation tasks on an OLE Automation object using properties and methods the object supports. For information on which properties and methods an OLE Automation object supports, see the documentation for the application that created the object.

See Also

OLE Automation.

Example

The following example uses the Object property of an unbound object frame named OLE1. Customer name and address information is inserted into an embedded word document formatted as a form letter with placeholders for the name and address information and boilerplate text in the body of the letter. The procedure replaces the address information for each record and prints the form letter. It doesn’t save copies of the printed form letter.


Sub PrintFormLetter_Click()
    Dim objWord As Object
    Dim strCustomer As String, strAddress As String
    Dim strCity As String, strRegion As String
    ' Assign the object property of control to variable.
    Set objWord = Me!OLE1.Object.Application.Wordbasic
    ' Assign customer address information to variables.
    Me!CompanyName.SetFocus
    strCustomer = Me!CompanyName.Text
    Me!Address.SetFocus
    strAddress = Me!Address.Text
    Me!City.SetFocus
    strCity = Me!City.Text & ", "
    Me!Region.SetFocus
    If Not IsNull(Me!Region.Text) Then
        strRegion = Me!Region.Text
    Else
        Me!Country.Setfocus
        strRegion = Me!Country.Text
    End If
    Me!OLE1.Action = acOLEActivate        ' Activate OLE control.
    objWord.StartOfDocument
    objWord.LineDown 2
    objWord.EndOfLine 1
    objWord.Insert strCustomer            ' Insert customer name.
    objWord.LineDown
    objWord.StartOfLine
    objWord.EndOfLine 1
    objWord.Insert strAddress            ' Insert address.
    objWord.LineDown
    objWord.StartOfLine
    objWord.EndOfLine 1
    objWord.Insert strCity & strRegion    ' Insert City and Region.
    objWord.FilePrint                    ' Print Word document.
    objWord.FileClose
    Set objWord = NothingSub