Access 2003 Merge to word document

G

Guest

I have been trying to put together a mail merge from an access database to
word with a custom interface for the end users. I have a table that records
information about each mail merge including a title, a description and the
query on which the mail merge is based.

My form displays this information so the user can recall what the purpose of
the mail merge was and open the document via a button click.

A similar button allows users to create a new mail merge document by
specifying a title description and query and then the code will create the
mail merge document, link it to the query and then open the document for
editing.

This works fine with my code for access 2000 and word 2000 but the
organization has some users working with access 2003 and word 2003 and the
code fails.

The code is listed below. When run from access 2003 to word 2003
objDoc.MailMerge.OpenDataSource fails giving a error message that i believe
comes from word saying "This operation can not be completed due to dialog or
database error"

Dim objWord As New Word.Application
Dim objDoc As Word.Document
Set objDoc = objWord.Documents.Add

savePath = Application.CurrentProject.Path & "\MailMerge\" & strDocName

'create new merge document
objWord.ActiveDocument.MailMerge.MainDocumentType = documentType
objDoc.SaveAs (savePath)
objDoc.MailMerge.OpenDataSource _
Name:=Application.CurrentProject.FullName, _
LinkToSource:=True, _
AddToRecentFiles:=False, _
Connection:="Query [" & strQueryName & "]", _
SQLStatement:="SELECT * FROM [" & strQueryName & "];"

DoCmd.OpenForm "NewMailMerge", acNormal, , , acFormEdit, acDialog
objDoc.SaveAs (savePath)

The above code works fine in an access 2000 to word 2000 mail merge.

What would be realy easy is if there is some way to trigger the
functionality behind the menu item found under "Tools > Office Links > Merge
it with Microsoft Office Word" with a query passed in from code as this
button achieves the functionality i am looking for but required a query to be
the active selection which is not what i want.

I have not been able to find a solution searching the net and the only
reference to my error message refers to creating a mail merge in word using
outlook contacts. this does not help much.

I hope i was clear I have spend a lot of time getting the mail merge to work
in office 2000 and need it to be compatable with more recent versions of
office.
 

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