Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Save Parts of Large Mailmerge as Separate Files
I have a very large list that that I want to email different parts of to
different departments. I'd like to save each department's letters into a separate file as part of the merge process. The question is how can I merge the document and have part of the merge saved to a new file each time the department name changes? Ideally, I would like the file name to be based on the department name. I've done work with macros similar to this before, but it's been years and I'm a bit rusty. Thanks for any advice. |
#2
|
|||
|
|||
You appear to have asked this in a number of Word neswgroups at least two of
which have received replies. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org John wrote: I have a very large list that that I want to email different parts of to different departments. I'd like to save each department's letters into a separate file as part of the merge process. The question is how can I merge the document and have part of the merge saved to a new file each time the department name changes? Ideally, I would like the file name to be based on the department name. I've done work with macros similar to this before, but it's been years and I'm a bit rusty. Thanks for any advice. |
#3
|
|||
|
|||
Run separate merges, one for each department, using the department name as
part of the query WHERE clause. Save each into a separate file. You could automate the whole process if you really need to, but unless you have a large number of departments or you're going to be doing this repeatedly, it's probably not worth the trouble. "John" wrote in message ... I have a very large list that that I want to email different parts of to different departments. I'd like to save each department's letters into a separate file as part of the merge process. The question is how can I merge the document and have part of the merge saved to a new file each time the department name changes? Ideally, I would like the file name to be based on the department name. I've done work with macros similar to this before, but it's been years and I'm a bit rusty. Thanks for any advice. |
#4
|
|||
|
|||
The problem is that I'm going to have about 2,000 pages (one per
employee)split over 125+ departments, so I really didn't want to run each separately - I was really looking to automate the process. Jezebel wrote: Run separate merges, one for each department, using the department name as part of the query WHERE clause. Save each into a separate file. You could automate the whole process if you really need to, but unless you have a large number of departments or you're going to be doing this repeatedly, it's probably not worth the trouble. "John" wrote in message ... I have a very large list that that I want to email different parts of to different departments. I'd like to save each department's letters into a separate file as part of the merge process. The question is how can I merge the document and have part of the merge saved to a new file each time the department name changes? Ideally, I would like the file name to be based on the department name. I've done work with macros similar to this before, but it's been years and I'm a bit rusty. Thanks for any advice. |
#5
|
|||
|
|||
Thanks
Doug Robbins wrote: The code in the macro provided below if for an entirely different purpose, but if you have the datasource ordered by Department, and you create a catalog type mailmerge with the department mergefield in a single cell table and execute that merge, then merge the letters to a new file, you could modify the macro so that it iterates through the catalog merge document to determine the number of records for each department , then grab that number of Sections from the formletter merge document and same them to a file with the name of the department and then repeat that process for each department: Dim source As Document, target As Document, scat As Range, tcat As Range Dim data As Range, stab As Table, ttab As Table Dim i As Long, j As Long, k As Long, n As Long Set source = ActiveDocument Set target = Documents.Add Set stab = source.Tables(1) k = stab.Columns.Count Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1, numcolumns:=k - 1) Set scat = stab.Cell(1, 1).Range scat.End = scat.End - 1 ttab.Cell(1, 1).Range = scat j = ttab.Rows.Count For i = 1 To stab.Rows.Count Set tcat = ttab.Cell(j, 1).Range tcat.End = tcat.End - 1 Set scat = stab.Cell(i, 1).Range scat.End = scat.End - 1 If scat tcat Then ttab.Rows.Add j = ttab.Rows.Count ttab.Cell(j, 1).Range = scat ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True ttab.Rows.Add ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False For n = 2 To k Set data = stab.Cell(i, n).Range data.End = data.End - 1 ttab.Cell(ttab.Rows.Count, n - 1).Range = data Next n Else ttab.Rows.Add For n = 2 To k Set data = stab.Cell(i, n).Range data.End = data.End - 1 ttab.Cell(ttab.Rows.Count, n - 1).Range = data Next n End If Next i |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can you save individual document pages as seperate word files? | Mailmerge | |||
Save Parts of Large Mailmerge as Separate Files | Microsoft Word Help | |||
Merge groups in large list to separate files | Microsoft Word Help | |||
Merge groups in large list to separate files | Mailmerge | |||
Save As...*.txt files | Microsoft Word Help |