Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2008

Tip: Looking for answers? Try searching our database.

error 5535 when running mail merge from ms access to word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rasta - 06 Jan 2008 01:46 GMT
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
Doug Robbins - Word MVP - 07 Jan 2008 10:25 GMT
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

Signature

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

> Hi,
>
[quoted text clipped - 62 lines]
>   End If
> End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.