Print Mail Merge Using VBA

K

Kenny G

Hi,

I have a table that is built for a mail merge in an Access DB. The data is
already linked to the Word document. I just want to open the Word document
and print out a document for each record.

I go directly to the word document and I can see that the records are linked
to the document.

I have written some code in order to open that document from inside Access
and just print out the document.

Would someone in the know take a look at the code below and see what I am
doing wrong. I can't see the mail merge data on the underlying document.
It doesn't print all the underlying records - just one document with the
printed mail merge setup.

Private Sub cmdOpenMailMergeOtherCom_Click()
On Error GoTo Err_cmdOpenMailMergeOtherCom_Click

Dim objWord As Word.Application
Dim objDoc As Word.Document

Set objWord = New Word.Application


'Make Document Visible
objWord.Visible = True

'Open Document Using Path
Set objDoc = objWord.Documents.Add("S:\Quality & Process
Improvement\QPI\Infection Control\CommDisease.dot")


'objWord.PrintOut
'objDoc.Close wdDoNotSaveChanges
'objWord.Quit



Exit_cmdOpenMailMergeOtherCom_Click:
Exit Sub

Err_cmdOpenMailMergeOtherCom_Click:
MsgBox Err.Description
Resume Exit_cmdOpenMailMergeOtherCom_Click


End Sub

Thanks for your assistance,
 
D

Doug Robbins

There is nothing in your code to execute the mailmerge. You need to use:

objdoc.MailMerge.Destination = wdSendToPrinter

You may also want to take a look at the article "How to do a mail merge to
the printer using VBA, without

displaying the Print dialog" at:

http://word.mvps.org/FAQs/MailMerge/MergeStraightToPrintrWVBA.htm




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

Kenny G

Doug,

Thank you for your reply. Things are working smoothly now. That web site
is a great source of assistance as well.
 

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