Mail Merge – create individual documents

D

DeanH

Word 2000SP3 on Windows 2000 SP4

I have set up a mail merge from an Excel source, this is not a problem. But
is it possible for the merge to automatically create individual documents
from the data set for each record?
Also is it possible for the new individual documents to be renamed with say
the “Name†field?

Many thanks in advance.
DeanH
 
D

Doug Robbins - Word MVP

See the "Individual Merge Letters" item on fellow MVP Graham Mayor's website
at:

http://www.gmayor.com/individual_merge_letters.htm

If you were using Word XP or later, the "Add-in to Merge Letters to Separate
Files" that I have written and that can be downloaded from that site would
allow you to create each letter as a separate file with a filename taken
from a field in the data source with a minimum of fuss.


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

DeanH

Many thanks Peter and Doug.
I shall give these instructions a go, so cross-fingers for me.

Thanks again.
DeanH
 
D

DeanH

Hi Doug.

The last macro (SplitMergeLetter, as I am Word2000) works wonderfully.
Just one comment, what script can I add to this macro to tidy up the
individual documents because they are saved with a Section Break (NextPage),
and one paragraph mark for the new blank page, at the end of each file.

This would just finish a wonderful job.
Many thanks again.
 
G

Graham Mayor

The macro does not *add* a section break to the document, but splits on the
section break and should not do what you report. If you merge just one
record does that merged document have an unwanted page? My guess is that
your merge document is just a tad too long to fit on the page without
forcing the final paragraph mark to a new page. Try deleting that last
paragraph mark (or reformatting it as 1 point size) so that it all stays on
the same page.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

DeanH

Thanks for the quick response.

My template is not too long, once merged the bottom line is over an inch
away from the footer. Due to the information I am merging (numbers and names)
the merged document never gets close to the footer.
I have merged just one page, this ends with a Section Break(Continuous), all
on one page.
Run the macro, now ends with Section Break (Next Page) and a blank new page
(obviously). Section Break (Continuous) has disappeared.
I understand that the macro doesnot add the section break, but can I slot in
to the macro some script to delete the Next Page before the individual file
is saved?

Many thanks
DeanH
 
G

Graham Mayor

The following macro contains the core code

Sub SplitCheck()
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
' .EndKey Unit:=wdStory
' .MoveLeft Unit:=wdCharacter, Count:=1
' .Delete Unit:=wdCharacter, Count:=1
End With
End Sub

The remmed out lines are the lines that are supposed to remove the errant
section break. Run this macro on a merged document and see what you end up
with. You should have one document with a section break at the end.
In that document record a macro of the steps it requires to move the cursor
to the end of the document, then to delete the section break.

Replace the remmed out lines with the code you have created then test again.
If that works substitute the lines in the original macro and let me know
what you come up with.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Try

With Selection
.Paste
.EndKey Unit:=wdStory
.TypeBackspace
.TypeBackspace
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Forget that - posted before testing properly :(

Try
With Selection
.Paste
.EndKey Unit:=wdStory
.TypeBackspace
.Delete Unit:=wdCharacter, Count:=1
End With

instead. This is a minor variation that works here - unfortunately I don't
have Word 2000 to check.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

DeanH

Many thanks Graham for your persistence.

I was testing the new macro when you sent this reply, I think we came to a
very similar solution.

From your previous reply x2, indicates that the macro at the bottom of the
Individual Merge Letters instruction sheet maybe an old version.

Below is the full macro that I am now using and it works perfectly, hooray!


Sub SplitMergeLetter()
' splitter Macro modified to save individual letters with
' information from data source. The filename data must be added to
' the top of the merge letter - see web article.

Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
Application.ScreenUpdating = False
With Selection

.HomeKey Unit:=wdStory
.EndKey Unit:=wdLine, Extend:=wdExtend
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

End With
sName = Selection
Docname = "D:\My Documents\Test\Merge\" & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.HomeKey Unit:=wdStory
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
.Delete

[The above code is to remove the file name text at the top of the document.
New additional code added here, to delete any page break at the end of the
new document.]

.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1

[End of new code]

End With
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend

End Sub


Many thanks again, and keep up the fantastic work you do here.
All the best
DeanH
 
G

Graham Mayor

It was an old version, aimed primarily at users who cannot access the
add-in, but it should have worked as it stands. As long as we got there in
the end ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Many thanks Graham for your persistence.

I was testing the new macro when you sent this reply, I think we came
to a very similar solution.

From your previous reply x2, indicates that the macro at the bottom
of the Individual Merge Letters instruction sheet maybe an old
version.

Below is the full macro that I am now using and it works perfectly,
hooray!


Sub SplitMergeLetter()
' splitter Macro modified to save individual letters with
' information from data source. The filename data must be added to
' the top of the merge letter - see web article.

Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
Application.ScreenUpdating = False
With Selection

.HomeKey Unit:=wdStory
.EndKey Unit:=wdLine, Extend:=wdExtend
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

End With
sName = Selection
Docname = "D:\My Documents\Test\Merge\" & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.HomeKey Unit:=wdStory
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
.Delete

[The above code is to remove the file name text at the top of the
document. New additional code added here, to delete any page break at
the end of the new document.]

.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1

[End of new code]

End With
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend

End Sub


Many thanks again, and keep up the fantastic work you do here.
All the best
DeanH

Graham Mayor said:
Forget that - posted before testing properly :(

Try
With Selection
.Paste
.EndKey Unit:=wdStory
.TypeBackspace
.Delete Unit:=wdCharacter, Count:=1
End With

instead. This is a minor variation that works here - unfortunately I
don't have Word 2000 to check.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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