save individual letters from a mail merge document

H

Horta

I am creating a 30 letter mail merge and I would like to be able to pdf each
letter to forward electronically. I have no problems with the mail merge, or
the pdf, but cannot find a way to seperate each letter without cutting and
pasting each letter into another document.
 
D

Doug Robbins

Assuming that you are using File>Print with a .PDFing thingy set to create
the PDF, use the following macro on the document created by executing the
mailmerge to a new document

Dim i as Long
For i = 1 to ActiveDocument.Sections.Count
ActiveDocument.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i
Next i


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
C

chartwell52655

How do I separate each document when the template I am merging from contains
section breaks?
 
D

Doug Robbins

Sub splitter()

' splitter Macro

' Macro created by Doug Robbins to save each letter created by a mailmerge
as a separate file.

Dim i As Long, Source as Document, Target as Document, Letter as Range
Set Source = ActiveDocument
For i = 1 to Source.Sections.Count
Set Letter = Source.Sections(i).Range
Letter.End=Letter.End-1
Set Target = Documents.Add
Target.Range=Letter
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i

End Sub

If you want each file to be named based on one of the fields in the data
source,
here's a method that I have used that involves creating a separate
catalog type mailmerge maindocument which creates a word document containing
a table in each row of which would be your data from the database that you
want to use as the filename.

You first execute that mailmerge, then save that file and close it. Then
execute the mailmerge that you want to create the separate files from and
with the
result of that on the screen, run a macro containing the following code
and when the File open dialog appears, select the file containing the table
created by the first mailmerge

' Throw Away Macro created by Doug Robbins
'
Dim Source As Document, oblist As Document, DocName As Range, DocumentName
As String
Dim i As Long, doctext As Range, target As Document
Set Source = ActiveDocument
With Dialogs(wdDialogFileOpen)
.Show
End With
Set oblist = ActiveDocument
Counter = 1
For i = 1 To oblist.Tables(1).Rows.Count
Set DocName = oblist.Tables(1).Cell(i, 1).Range
DocName.End = DocName.End - 1

'Change the path in the following command to suit where you want to save
the documents.
DocumentName = "I:\WorkArea\Documentum\" & DocName.Text
Set doctext = Source.Sections(i).Range
doctext.End = doctext.End - 1
Set target = Documents.Add
target.Range.FormattedText = doctext
target.SaveAs FileName:=DocumentName
target.Close
Next i


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
S

sayling

Hmmm

This almost sounds like what I am looking for...

I have a document that gets merged to email automatically ( ie it runs
unattended at present). I am looking to try and get the subject of the email
to equal a couple of merge fields from the document (such as a date field and
a customer field, both held in the data source) using Word and Outlook 2000.

I get the impression that it would be easier to have the merge set to
produce different documents and let the email subject default to the document
name. So it sounds as though your 'throw away' splitter might do the job, but
(and you'll have to excuse my vba ignorance here) it appears that manual
intervention is required here...

Have I missed the point, or can the whole process be automated?
 
C

Charles Kenyon

See http://www.gmayor.com/individual_merge_letters.htm which does
automatically name the documents. See
http://addbalance.com/word/wordwebresources.htm#mailmerge for more mailmerge
links.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
S

sayling

Thanks, Charles. I've already accessed the page from Graham, which deals with
the splitting, but I can't see how to then get those individual files, from a
folder that will have it's contents increase in number every day, emailed to
a different address within each document, all unattended. And the second link
doesn't seem to throw much light on the problem.

Again, am I missing something (else)?
 

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