kamur
asked on
Split a mail-merged document into one page word documents each
Hello,
I have a mail-merge process where I insert 4 fields into a word document. The mail-merged document is usually one big word document close to 2,000 pages. I want to split this large word document into one page document each and the name of each document should be the value of the first field among the 4 fields that I am inserting.
That is, I am inserting 4 fields such as: client number, client name, client address and client phone in the mail-merge process. Therefore, the name of each split one page documents needs to be the respective client number value that is inserted for that page. (client number.doc).
Please advise how to do this
Thanks
Kamur
I have a mail-merge process where I insert 4 fields into a word document. The mail-merged document is usually one big word document close to 2,000 pages. I want to split this large word document into one page document each and the name of each document should be the value of the first field among the 4 fields that I am inserting.
That is, I am inserting 4 fields such as: client number, client name, client address and client phone in the mail-merge process. Therefore, the name of each split one page documents needs to be the respective client number value that is inserted for that page. (client number.doc).
Please advise how to do this
Thanks
Kamur
I was so concentrating on the document name this morning that I forgot about what to save. I'll come back soon with a better macro.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sub SplitMergeResult()
Dim sec As Section
Dim rng As Range
Dim strName As String
Dim DocA As Document
Dim DocB As Document
Dim rngStart As Integer
If Selection.Sections(1).Inde
MsgBox "Please select the first name and restart this macro"
End
End If
rngStart = Selection.Start
Debug.Print rngStart
Set DocA = ActiveDocument
For Each sec In DocA.Sections
Set rng = sec.Range
rng.Start = sec.Range.Start + rngStart
strName = Trim$(rng.Words(1).Text)
Set DocB = Documents.Add
DocB.SaveAs strName & ".doc"
Debug.Print strName
DocB.Close
Next sec
End Sub