View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
magicdds magicdds is offline
external usenet poster
 
Posts: 15
Default Printing merged data into 2 columns

Thanks for the help so far. I almost have what I need.

The problem is that when I merge the data to the word document, while the
data prints properly in each cell, the height of the cell is too tall. It
seems that the cell adds extra carriage returns to the merged document, due
to the length of the conditional statements that are in the cell. How can I
get the document to print with no empty lines between each row of the the
table?




"Doug Robbins - Word MVP" wrote:

In your catalog (or directory) mail merge main insert a three column one row
table and in the first row, set up the following field construction:

{ IF { MERGESEQ } = "1" "{ MERGEFIELD City }{ SET Place2 { MERGEFIELD
City} }" "{ SET Place1 { MERGEFIELD City }}" }{ IF { Place2 } { Place1 }
"{ MERGEFIELD City }" "" }

In the second column, insert

{ MERGEFIELD Employee }

and in the third column, insert

{ MERGEFIELD Amount }{SET Place2 { MERGEFIELD City} }
--
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

"magicdds" wrote in message
...
This is similar to the code that I used to merge my Access Data into the
Word
Letter:

{ IF { MERGESEQ } = "1" "{ MERGEFIELD City }" "" }ENTER
{ SET Place1 { MERGEFIELD City }}ENTER
{ If { Place2 } { Place1 }"ENTER
{ MERGEFIELD City }ENTER
ENTER
{ MERGEFIELD Employee }{ MERGEFIELD Sales }" "{ MERGEFIELD Employee }{
MERGEFIELD Sales }" }{ SET Place2 { MERGEFIELD City }}ENTER


I just need to get { MERGEFIELD Employee }{ MERGEFIELD Sales } to tab over
to a certain column. Isn't there an easier way than to write all the code
below (especially since I'm not familiar with most of it)?



"Doug Robbins - Word MVP" wrote:

If you create a Catalog (or in Word XP and later, it's called Directory)
type mailmerge main document with the mergefields in the cells of a one
row
table in the mailmerge main document with the keyfield (City) in the
first
cell in the row and then execute that merge to a new document and then
run
the following macro with that new document as the active document, it
will
create a new document with the data arranged in the way that you want.

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)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
For n = 2 To k
Set data = stab.Cell(1, n).Range
data.End = data.End - 1
ttab.Cell(1, n).Range = data
Next n
j = ttab.Rows.Count
For i = 2 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 = False
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).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).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

"magicdds" wrote in message
...
I Used mail merge to create a list sorted by category as per Article ID
211303. It works just as described. The article has the "City" printed
followed by the "Employees" and "sales" listed in a single column. I
want
my
results to look as follows:

Atlanta: Smith $3000
Gates $50,000
Henderson $10,000

Houston: Jones $8,000
Kelly $9,000
Peterson $0

How can I program in that after "City" is printed, the cursor needs to
tab
over to the right column, prior to printing each of the "Employees" .
Also,
if the "Employees" data is so long that it continues over to the next
line,
it needs to first tab over to the right side column before continuing
to
print.

Thanks for any help you can give.
Mark