Insert excel data into word via mail merge

J

Jane

I want to print year end summaries to the employees who have stock sale tax
reported on their W2. The word doc. that will be sent out contains standard
data that these emp. will receive. However the numbers are in excel. How do
I merge this information into the doc. file in a way so that I don't have to
do it manually for 200 emp.
For eg:
Joe Smith
The attached file contains records of the income that has been reported on
your W2 pursuant to your sale of ESPP shares/options exercise.

Grt dt. Grt.type Ex. Dt Opt. ex. Opt. price FMV at ex Total gain
9/29/2002 Incentive 8/27/2004 3,125 $12.7054 $39,704.50
9/29/2002 Incentive 10/29/2003 520 $13.5990 $7,071.49 Total 48,203.34
Reported in W-2 48,203.34

I am using word 03 and excel 03
Hope this makes sense.
Thanks
 
D

Doug Robbins - Word MVP

Mail merge in Word cannot really hand a multiple items (transactions in your
case) per condition (Employee in your case) situation.

If you have Microsoft Access, I would recommend transferring the data into
Access and then use an Access Report.

Otherwise, you could try further developing the following macro. It would
take some work, but it would be quite feasible to get it to do what you
want.

' Macro to create multiple items per condition 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.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
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


--
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
 

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