Component doesn't support automatrion?

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
 
D

Dev Ashish

' Assign object property of control to variable.
Set objWord = Me!OLE1.Object.Application.Wordbasic

Try setting a reference to Word/Document itself instead of WordBasic.
Dim doc as Word.Document ' or as Object
Set doc = Me!OLE1.Object

-- Dev
 
A

Albert D. Kallal

It looks like you are trying to automate a word mail merge.

I am going to suggest you give my sample code a try. It is automatically for
any form that you use, and you DO NOT have to write a bunch of code with the
field names hard coded into your application (my sample makes the word
template for you).

So, give my code a try, as it seems exactly what you need.

Check it out at:

http://www.attcanada.net/~kallal.msn/msaccess/msaccess.html
 
G

Guest

Nope,

Still giving me the error.

Thanks,
Don
-----Original Message-----


Try setting a reference to Word/Document itself instead of WordBasic.
Dim doc as Word.Document ' or as Object
Set doc = Me!OLE1.Object

-- Dev
.
 
G

Guest

Nope,

Just trying to find out the file name refered to in the
linked OLE document in my Access database.

Thanks,
Don
 
D

Dev Ashish

Still giving me the error.

At what line? I just embedded a Word object in an unbound form and put in
this code behind a button and it seems to work for me without any errors.

Private Sub Command1_Click()
Dim objWord As Object, objDoc As Object
Me.OLEUnbound0.Action = acOLEActivate
Set objDoc = Me.OLEUnbound0.Object
Set objWord = objDoc.Parent
Stop
End Sub


-- Dev
 
G

Guest

On the reference to the 'Object':
Set objDoc = Me.OLEUnbound0.Object

Will try again with your exact code.

Thanks,
Don
 
G

Guest

Nope, copied exact code and changed only reference to
unbound container (OLEUnbound0 to OLEUnbound34, which is
used in my form.)
Have deposited a link to a very simple word document and
see that the 'Source Doc' property for OLEUnbound34
points to the right file.

Using Access 2002 SP2, will see if there are further
patches????

Thanks,
Don
 
G

Guest

Got it working...
Must have been something in the DB itself. It was
converted from Access 97 and has appearently pushed the
limits of file size throughout its existence.
I imported the tables, etc to a brand new blank file and
things seem happier.

Thanks for the assist!
Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top