error 5535 when running mail merge from ms access to word

R

Rasta

Hi,

I'm running the following code in ms access to generate mail merge documents
in word. On certain records I get the error 5535 on the execute line. I have
no idea what would be causing this, but every time word opens up a new
window with a tiny black square and says 'picture in unnamed'. When I remove
the header image from the main merge document the merge seems to run fine.
The header image is a microsoft word picture and it needs to be in the file.
Any help with this would be appreciated.

code: - I know it's messy but this is my first stab at it

Dim objWord As Word.Document
Dim sletter As String
Dim rs As Recordset
Dim rsErisa As Recordset
Dim ssql As String
Dim db As Database
Dim sFilename As String

Set objWord = GetObject("C:\projects\audit1408\4A Full scope audit and
11k - 5500 sep3.doc", "Word.Document")

Set db = CurrentDb

Set rsErisa = db.OpenRecordset("select * from [Erisa table]")

If Not rsErisa.EOF Then

Do Until rsErisa.EOF

ssql = "insert into tblerisaletterstemp select * from [erisa table] where
planid=" & rsErisa("planid")
db.Execute ssql

Set rs = db.OpenRecordset("select * from qryEngagementletters")

If Not rs.EOF Then

Do Until rs.EOF

If (Not rs("[Client list.client name]") = "" And Not IsNull(rs("[Client
list.client name]"))) Then

sFilename = rs("[Client list.client name]") & ".doc"

objWord.Application.Visible = True
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.ActiveDocument.SaveAs ("C:\projects\audit1408\" &
sFilename)
objWord.Application.ActiveDocument.Close

End If

ssql = "delete * from tblerisaletterstemp"
db.Execute ssql

rs.MoveNext
Loop
End If

rsErisa.MoveNext
Loop
End If
End Function
 
D

Doug Robbins - Word MVP

To get assistance on that, it would be best to ask in an Access newsgroup,
but you should find some things
of interest of fellow Access MVP, Albert Kallal's website at:

http://www.members.shaw.ca/AlbertKallal/wordmerge/index.html

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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