Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default How to get Excel results into Word

I generated two Excel worksheets of data for about 700 items. One has
one line of information for each item, the other has multiple lines
for each item. Each item has a single unique identifier. I need to
build a report in Word with the single-line results in a header and
the multi-line results below.

This would be easier in Access if I could build a report from two
tables with a linked key field - but the Powers That Be didn't see fit
to give me that tool. So I'm trying to make do with what I've got!

About the only thought I have so far is to create a Word template with
my header as a table and a bookmark below it. With the two Excel
worksheets, iterate through the single-line results and build an array
to populate the table cells, then capture the unique key and for each
entry in the multi-line results that matches the key, build an array
to dump into the bookmark. Save, close, open new, lather, rinse,
repeat.

Is there an easier way?

Ed

  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 772
Default How to get Excel results into Word

I've done something very similar a while back, I took an identical approach,
it takes a bit but your thought process is good.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Ed from AZ" wrote:

I generated two Excel worksheets of data for about 700 items. One has
one line of information for each item, the other has multiple lines
for each item. Each item has a single unique identifier. I need to
build a report in Word with the single-line results in a header and
the multi-line results below.

This would be easier in Access if I could build a report from two
tables with a linked key field - but the Powers That Be didn't see fit
to give me that tool. So I'm trying to make do with what I've got!

About the only thought I have so far is to create a Word template with
my header as a table and a bookmark below it. With the two Excel
worksheets, iterate through the single-line results and build an array
to populate the table cells, then capture the unique key and for each
entry in the multi-line results that matches the key, build an array
to dump into the bookmark. Save, close, open new, lather, rinse,
repeat.

Is there an easier way?

Ed


  #3   Report Post  
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to get Excel results into Word

I think a pivot table in Excel could arrange a report like you want, have
you posed this question in the Excel forum?
http://www.cpearson.com/excel/links.htm


I generated two Excel worksheets of data for about 700 items. One has
one line of information for each item, the other has multiple lines
for each item. Each item has a single unique identifier. I need to
build a report in Word with the single-line results in a header and
the multi-line results below.

This would be easier in Access if I could build a report from two
tables with a linked key field - but the Powers That Be didn't see fit
to give me that tool. So I'm trying to make do with what I've got!

About the only thought I have so far is to create a Word template with
my header as a table and a bookmark below it. With the two Excel
worksheets, iterate through the single-line results and build an array
to populate the table cells, then capture the unique key and for each
entry in the multi-line results that matches the key, build an array
to dump into the bookmark. Save, close, open new, lather, rinse,
repeat.

Is there an easier way?

Ed


--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 2,836
Default How to get Excel results into Word

I think this will give you what you want:

1) Create a UserForm
2) Create a ListBox
3) Create a ControlButton

Double-click the control button and paste this code into the module:
Private Sub CommandButton1_Click()

Dim i As Integer, Addressee As String
Addressee = ""
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks("Addressee").Range.Insert After Addressee
UserForm1.Hide

End Sub



Sub UserForm_Initialize()

Dim i As Integer, Addressee As String

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long

' Open the database
Set db = OpenDatabase("C:\Documents and
Settings\xxx\Desktop\Contacts.xls", False, False, "Excel 8.0")

' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM `List`")

' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With

' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = rs.Fields.Count

' Load the ListBox with the retrieved records
ListBox1.Column = rs.GetRows(NoOfRecords)
'ListBox1.List = rs.GetRows(NoOfRecords) 'Transposed List

' Cleanup
rs.Close
db.Close

'AddressBlock = db

Set rs = Nothing
Set db = Nothing


End Sub

Hope that helps,
Ryan---

--
RyGuy


"Russ" wrote:

I think a pivot table in Excel could arrange a report like you want, have
you posed this question in the Excel forum?
http://www.cpearson.com/excel/links.htm


I generated two Excel worksheets of data for about 700 items. One has
one line of information for each item, the other has multiple lines
for each item. Each item has a single unique identifier. I need to
build a report in Word with the single-line results in a header and
the multi-line results below.

This would be easier in Access if I could build a report from two
tables with a linked key field - but the Powers That Be didn't see fit
to give me that tool. So I'm trying to make do with what I've got!

About the only thought I have so far is to create a Word template with
my header as a table and a bookmark below it. With the two Excel
worksheets, iterate through the single-line results and build an array
to populate the table cells, then capture the unique key and for each
entry in the multi-line results that matches the key, build an array
to dump into the bookmark. Save, close, open new, lather, rinse,
repeat.

Is there an easier way?

Ed


--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pasting Word Text - strange results Alan Smith Excel Discussion (Misc queries) 0 November 25th 09 07:12 PM
Using 2007 Office EXCEL or WORD "SEND" Results in General Mail Fai Jerry Link Excel Discussion (Misc queries) 1 December 29th 08 04:54 PM
Conditional Sum Argument results do not equal cell results Excel Randy R Mullins Excel Worksheet Functions 3 August 9th 06 07:16 PM
Subtotal results without word "Total" achidsey Excel Worksheet Functions 1 September 13th 05 01:46 PM
Word Search from Excel results in Duplicates Sarvesh Excel Programming 2 December 23rd 03 05:23 PM


All times are GMT +1. The time now is 07:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"