Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2003 Directory Mail merge from Excel 2003
Hi
I have a list of questions in a spreadsheet that I am filtering to generate checklists for different respondents. At the moment I am using a directory mail merge to generate the different checklists, filtering inside the 'mail merge recipients' dialog box. In the word doc, I have a table set up to contain the question and a space for response. So at the moment, I get a series of tables with a new question in each. The questions though, can be broken into subject areas, so I'd like to display the subject (outside the table I've set up) on the word doc. i.e. have a heading and then the tables relating to to that heading and then another heading. Is there a way to do this, I've tried playing around with nested IF's but I haven't been able to get the order right. If I use an IF, can the output be a table which contains mergefields? Thanks |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2003 Directory Mail merge from Excel 2003
If you have the Subject in the first cell of the one row table in the
Directory type mail merge main document and then after executing the merge to a new document you run the following macro, it will create separate tables with the records for each Subject in them. If that is not exactly what you want, with a bit of further development, you should be able to get it to do what you want. ' Macro to create multiple items per condition in separate tables from a directory type mailmerge 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 -- 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 "SeamusM" wrote in message ... Hi I have a list of questions in a spreadsheet that I am filtering to generate checklists for different respondents. At the moment I am using a directory mail merge to generate the different checklists, filtering inside the merge recipients' dialog box. In the word doc, I have a table set up to contain the question and a space for response. So at the moment, I get a series of tables with a new question in each. The questions though, can be broken into subject areas, so I'd like to display the subject (outside the table I've set up) on the word doc. i.e. have a heading and then the tables relating to to that heading and then another heading. Is there a way to do this, I've tried playing around with nested IF's but I haven't been able to get the order right. If I use an IF, can the output be a table which contains mergefields? Thanks |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Directory in Mail Merge Word 2003 | Mailmerge | |||
Word 2003 Mail Merge cannot open Excel 2003 document | Microsoft Word Help | |||
Word 2003 SP2: Missing records in mail-merge from Excel to directory | New Users | |||
Grouping an Excel Field in a Word 2003 Directory Merge | Mailmerge | |||
Mail Merge Word 2003 Excel 2003 database | Mailmerge |