Mailmerge to Word question - printing different sections

M

Mike_Gator14

Hi, I would like to perform a mailmerge from within access to word.

I have a word document that is divided into different printable
sections, based on a value in an access query, f.i.

if the value is 1 then print section 1, 6 and 7
if the value is 2 then print section 2 and 4
etc.

In each record this value is checked and then the matching sections
are to be printed out.

In word I can do it like this:

Documents("Name.doc").MailMerge.DataSource.ActiveRecord =
wdFirstRecord
If ActiveDocument.MailMerge.DataSource.DataFields("Name").Value = 1
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:=
_
wdPrintDocumentContent, Copies:=1, Pages:="s1, s6, s7", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False,
_
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End If
etc.

and everything works fine

How I can do the same but then from access?

I have the following code:

stMergeDoc = "E:\Name.doc"

Set objWord = GetObject(stMergeDoc, "Word.Document")

objWord.Application.Visible = True

objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="QUERY QryName", _
SQLStatement:="Select * from [QryName]"
objWord.MailMerge.Destination = wdSendToPrinter
objWord.MailMerge.Execute

I guess the code has to be somewhere at the 'wdSendToPrinter', but I
haven't got a clue.

Thank you,

Mike
 
C

Cindy M -WordMVP-

Hi Mike_Gator14,

I'm not sure I understand the question, but let me take a shot at it.

If you send the mail merge to a new document you can then print that
document the same way as you show for non-mail merge. You just have to
be aware that, unless you've chosen the merge type catalog/directory
that you'll get a section break between each record, besides the ones
you've created in the main merge document.

What might make more sense would be to only include the text you want
to actually print, for each record. You could have all the various
"sections" in an outside document; each section within a bookmark. Use
an IncludeText field with an IF field to test the values for each
record, and link to the corresponding bookmark (or to an "empty"
bookmark if a section should be surpressed).
I have a word document that is divided into different printable
sections, based on a value in an access query, f.i.

if the value is 1 then print section 1, 6 and 7
if the value is 2 then print section 2 and 4
etc.

In each record this value is checked and then the matching sections
are to be printed out.

In word I can do it like this:

Documents("Name.doc").MailMerge.DataSource.ActiveRecord =
wdFirstRecord
If ActiveDocument.MailMerge.DataSource.DataFields("Name").Value = 1
Then
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:=
_
wdPrintDocumentContent, Copies:=1, Pages:="s1, s6, s7", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False,
_
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End If
etc.

and everything works fine

How I can do the same but then from access?

I have the following code:

stMergeDoc = "E:\Name.doc"

Set objWord = GetObject(stMergeDoc, "Word.Document")

objWord.Application.Visible = True

objWord.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="QUERY QryName", _
SQLStatement:="Select * from [QryName]"
objWord.MailMerge.Destination = wdSendToPrinter
objWord.MailMerge.Execute

I guess the code has to be somewhere at the 'wdSendToPrinter', but I
haven't got a clue.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
M

Mike_Gator14

Hi Cindy,
You just have to
be aware that, unless you've chosen the merge type catalog/directory
that you'll get a section break between each record, besides the ones
you've created in the main merge document.

Well this is a problem, it doesn't work because I have to much pages
and differences within sections
What might make more sense would be to only include the text you want
to actually print, for each record. You could have all the various
"sections" in an outside document; each section within a bookmark. Use
an IncludeText field with an IF field to test the values for each
record, and link to the corresponding bookmark (or to an "empty"
bookmark if a section should be surpressed).

Hadn't thought of that yet, will try this!

Thanks for your reply!

Mike
 

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