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

Signature
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
> How do I separate each document when the template I am merging from
> contains
[quoted text clipped - 19 lines]
>> > and
>> > pasting each letter into another document.
sayling - 22 Mar 2005 15:17 GMT
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?
> Sub splitter()
>
[quoted text clipped - 79 lines]
> >> > and
> >> > pasting each letter into another document.
Charles Kenyon - 22 Mar 2005 15:59 GMT
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.

Signature
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.
> Hmmm
>
[quoted text clipped - 111 lines]
>> >> > and
>> >> > pasting each letter into another document.
sayling - 25 Mar 2005 17:19 GMT
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)?
> See http://www.gmayor.com/individual_merge_letters.htm which does
> automatically name the documents. See
[quoted text clipped - 115 lines]
> >> >> > and
> >> >> > pasting each letter into another document.