Hi Cindy,
Something like this should do it (a modification of Ibby's code at
http://word.mvps.org/FAQs/InterDev/FillListBoxFromXLDAO.htm):
Dim db1 As DAO.Database, db2 As DAO.Database
Dim rs1 As DAO.Recordset, rs2 As DAO.Recordset
Dim NoOfRecords As Long, i As Long, j As Long, flds1 As Long, flds2 As
Long
Dim Target As Document
' Open the databases
Set db1 = OpenDatabase("D:\Excel\Book1.xls", False, False, "Excel 8.0")
Set db2 = OpenDatabase("D:\Excel\Book2.xls", False, False, "Excel 8.0")
' Retrieve the recordsets Database1 and Database2 are named ranges in
Book1 and Book2 respectively
' The first row of the named range will not be brought in by this
procedure. There for if it is desired to bring in
' the field names, insert a blank row before the row in which the
fieldnames appear and include that blank row
' in the named range.
Set rs1 = db1.OpenRecordset("SELECT * FROM Database1")
Set rs2 = db2.OpenRecordset("SELECT * FROM Database2")
' Determine the number of retrieved records
With rs1
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
flds1 = rs1.Fields.Count
flds2 = rs2.Fields.Count
' Create a document into which the information will be inserted
Set Target = Documents.Add
For i = 1 To NoOfRecords
For j = 0 To flds1 - 1
Target.Range.InsertAfter rs1.Fields(j) & ","
Next j
For j = 0 To flds2 - 2
Target.Range.InsertAfter rs2.Fields(j) & ","
Next j
Target.Range.InsertAfter rs2.Fields(j) & vbCr
rs1.MoveNext
rs2.MoveNext
Next i
' Clean up
rs1.Close
rs2.Close
db1.Close
db2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db1 = Nothing
Set db2 = Nothing
--
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