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 / Programming / July 2007

Tip: Looking for answers? Try searching our database.

Positioning Data in Indivisual Cells within a Table using VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Romine - 27 Jul 2007 14:47 GMT
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
 
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.