Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / December 2004

Tip: Looking for answers? Try searching our database.

Insert excel data into word via mail merge

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jane - 22 Dec 2004 22:33 GMT
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
Doug Robbins - Word MVP - 22 Dec 2004 22:53 GMT
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

Signature

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

> 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
[quoted text clipped - 14 lines]
> Hope this makes sense.
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.