I am importing data from an AS/400 using OLE DB/ADO and wish to
populate a table with data.
I am reading a Primary file which has header information, and I need
to load detail from two additional files into the Table. The number
of rows within the table must be variable.
I would like to control loading the table by cell. For example, load
Name in Row 1, Column 1, Amount #1 in Row 1, Column 2, Amount #2 in
Row 1, Column 3, Total in Row 1, Column 4....then read the next record
and start loading in Row 2...and so on.
So, my question is this; How do I load data into cells of a table and
allow the table to be a variable length?
Thanks,
Romine
old man - 30 Jul 2007 18:20 GMT
Hi,
You can use this code to start....
Sub crtable()
Dim range1 As Range
Set range1 = ActiveDocument.Range(0, 0)
Dim tble1 As Table
Dim currow As Integer
currow = 0
Set tble1 = ActiveDocument.Tables.Add(range1, 1, 3)
For currow = 1 To 5
tble1.Rows.Add beforerow:=tble1.Rows(currow)
tble1.Rows(currow).Cells(1).Range.Text = currow
Next
End Sub
You should add error handling and break out of the for loop when you run out
of data...
Old Man
> I am importing data from an AS/400 using OLE DB/ADO and wish to
> populate a table with data.
[quoted text clipped - 14 lines]
>
> Romine