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
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