G
Guest
When I run this code from Access's 'Object' Help example
I get the error: "Component doesn't support automation"
Sub PrintFormLetter_Click()
Dim objWord As Object
Dim strCustomer As String, strAddress As String
Dim strCity As String, strRegion As String
' Assign object property of control to variable.
Set objWord = Me!OLE1.Object.Application.Wordbasic
' Assign customer address to variables.
strCustomer = Me!CompanyName
strAddress = Me!Address
strCity = Me!City & ", "
If Not IsNull(Me!Region) Then
strRegion = Me!Region
Else
strRegion = Me!Country
End If
' Activate ActiveX control.
Me!OLE1.Action = acOLEActivate
With objWord
.StartOfDocument
' Go to first placeholder.
.LineDown 2
' Highlight placeholder text.
.EndOfLine 1
' Insert customer name.
.Insert strCustomer
' Go to next placeholder.
.LineDown
.StartOfLine
' Highlight placeholder text.
.EndOfLine 1
' Insert address.
.Insert strAddress
' Go to last placeholder.
.LineDown
.StartOfLine
' Highlight placeholder text.
.EndOfLine 1
' Insert City and Region.
.Insert strCity & strRegion
.FilePrint
.FileClose
End With
Set objWord = Nothing
End Sub
I get the error: "Component doesn't support automation"
Sub PrintFormLetter_Click()
Dim objWord As Object
Dim strCustomer As String, strAddress As String
Dim strCity As String, strRegion As String
' Assign object property of control to variable.
Set objWord = Me!OLE1.Object.Application.Wordbasic
' Assign customer address to variables.
strCustomer = Me!CompanyName
strAddress = Me!Address
strCity = Me!City & ", "
If Not IsNull(Me!Region) Then
strRegion = Me!Region
Else
strRegion = Me!Country
End If
' Activate ActiveX control.
Me!OLE1.Action = acOLEActivate
With objWord
.StartOfDocument
' Go to first placeholder.
.LineDown 2
' Highlight placeholder text.
.EndOfLine 1
' Insert customer name.
.Insert strCustomer
' Go to next placeholder.
.LineDown
.StartOfLine
' Highlight placeholder text.
.EndOfLine 1
' Insert address.
.Insert strAddress
' Go to last placeholder.
.LineDown
.StartOfLine
' Highlight placeholder text.
.EndOfLine 1
' Insert City and Region.
.Insert strCity & strRegion
.FilePrint
.FileClose
End With
Set objWord = Nothing
End Sub