Merging to separate documents

P

Peter

This is one of the most commonly asked questions on this board:

How can I merge to separate documents instead of one big file? - AND-
How can I have each separate document be named based on a data field?

I also know that the answer is typically a macro, that while it works, is unable to reference the data file to name the subsequent documents. You are left with File1.doc, File2.doc, etc.

I have had a use for such a feature for over a decade now and keep waiting for Microsoft to add that as a mail merge option. As we become more dependent on electronic files and less dependent on paper ouptput, I have been very surprised that this issue hasn't been addressed.

Is this the proper forum to address this?
Does anyone from Microsoft who makes User Interface decisions read these forums?
I think this would be a great place to find out features that users actually want and need in their Office applications.
 
J

Johnmichael Monteith

I just posted a similar question, except I want to merge to separate
templates that are already in place.

It sounds like what you are looking for could be a fit for this solution:
http://support.microsoft.com/?kbid=211786

jp


Peter said:
This is one of the most commonly asked questions on this board:

How can I merge to separate documents instead of one big file? - AND-
How can I have each separate document be named based on a data field?

I also know that the answer is typically a macro, that while it works, is
unable to reference the data file to name the subsequent documents. You are
left with File1.doc, File2.doc, etc.
I have had a use for such a feature for over a decade now and keep waiting
for Microsoft to add that as a mail merge option. As we become more
dependent on electronic files and less dependent on paper ouptput, I have
been very surprised that this issue hasn't been addressed.
Is this the proper forum to address this?
Does anyone from Microsoft who makes User Interface decisions read these forums?
I think this would be a great place to find out features that users
actually want and need in their Office applications.
 
D

Doug Robbins - Word MVP

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 post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
Peter said:
This is one of the most commonly asked questions on this board:

How can I merge to separate documents instead of one big file? - AND-
How can I have each separate document be named based on a data field?

I also know that the answer is typically a macro, that while it works, is
unable to reference the data file to name the subsequent documents. You are
left with File1.doc, File2.doc, etc.
I have had a use for such a feature for over a decade now and keep waiting
for Microsoft to add that as a mail merge option. As we become more
dependent on electronic files and less dependent on paper ouptput, I have
been very surprised that this issue hasn't been addressed.
Is this the proper forum to address this?
Does anyone from Microsoft who makes User Interface decisions read these forums?
I think this would be a great place to find out features that users
actually want and need in their Office applications.
 
B

Bob S

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

Note that you must be very sure that no other user can add or delete a
record from the database between the two merges!

If it is inconvenient to lock other users out of the database, it
should be possible to do the job with one merge. (This might also save
a little time.) The idea would be to include the filename-generating
field in the form letter, formatting that merge field in a distinctive
style. (The style could be one point high and white if you don't want
it to display.)

After the merge, run a macro that uses Find to look at each
distinctively styled field in succession, generating the name and
saving that section.

It might even be possible to use a mail merge event to look at the
distinctively styled field in each record as it is generated, and save
immediately. This would be a little trickier, and would only work on
recent versions.

Bob S
 

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