Hi NotGood
TransferText will not help you here. It is only useful for
importing/exporting from fixed width or delimited *text* files.
You need to write some code to:
1. Open your document
2. Iterate through all its tables
3. For each table, iterate through all its rows
4. Extract the data values from each cell in the row
5. Do whatever with the data (write them to a new record in your table)
I'm anticipating your next question will be "how?" ;-) so here is some code
that should get you started:
Function ReadWordTables()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdTbl As Word.Table
Dim wdRow As Word.Row
Dim sCell1 As String, sCell2 As String
On Error GoTo ProcErr
Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open( _
CurrentProject.Path & "\TestReadFromTables.doc", _
ReadOnly:=True)
For Each wdTbl In wdDoc.Tables
For Each wdRow In wdTbl.Rows
sCell1 = wdRow.Cells(1).Range.Text
sCell2 = wdRow.Cells(2).Range.Text
' strip off vbCr/vbTab (end of cell marker)
sCell1 = Left(sCell1, Len(sCell1) - 2)
sCell2 = Left(sCell2, Len(sCell2) - 2)
' do something with values
Debug.Print sCell1, sCell2
' of course, you would write them to your table!
Next
Next
ProcEnd:
wdDoc.Close
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
Exit Function
ProcErr:
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
Resume ProcEnd
End Function
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
NotGood@All said:
I get Word documents that have tables (200), the tables consists of 2
fields;
1 is the item number and the other is the details of that item. I would
like
to append both the item number and the text to a table that has fields
named
"ItemNumber" and "Description". Can code be written so no matter how many
items are on the agenda they can be appended??