Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Data From Word Table 1

Status
Not open for further replies.

idbr

MIS
Joined
May 1, 2003
Messages
247
Location
GB
Hi,

Does anyone know how to open a word document, find a table and then extract the data within that table to Access?

The table will be organised by rows:

FieldHeader DataHeader
DataPoint1 DataItem1
DataPoint2 DataItem2
DataPoint3 DataItem3
DataPoint4 DataItem4

I want to extract the data to a table format:

DataPoint1 DataPoint2 DataPoint3 DataPoint4
DataItem1 DataItem2 DataItem3 DataItem4

The data points will always be the same, as will their names and order within the table. The table will always be in page 1 of the document, but may be in a different physical position from document to document.

I can do everything up to opening the word doc, then I plan to loop through the table rows to populate an array. Once I've got the data into the array its a simple enough job to populate the table in my Access db.

So I guess it boils down to:

How do I find & reference the table?
How do I loop through the table rows to populate the array?

I run A2002 on XP.

Thanks in advance, Iain
 
Hi,

Look at GetObject. You must also set a reference to the Microsoft Word n.m Object Library in the VB Editor via Tools/References. Then referencing a table would be somehting like this...
Code:
  Dim wd as Word.Document, tbl as Word.Table

  Set wd = GetObject(YourWordDocPathName)
...
  for each tbl in wd.Tables
    for each r in tbl.rows
       for each c in tbl.columns
         msgbox "row is: " & r & " col is: " & c & " value is : " & tbl.cells(r,c).value
       next
    next
  next


Skip,

[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue]


 
Just the ticket Skip, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top