View Single Post
  #4  
Old June 1st, 2010, 05:42 AM posted to microsoft.public.word.docmanagement
Graham Mayor
external usenet poster
 
Posts: 18,297
Default inserting table data from a Word document into an Access table

What you are missing is that the message box is only to illustrate that the
macro works. As suggested earlier *replace* the message box with the
commands to send the content to your Access table. It's the Access
programming I am unfamiliar with.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"s" wrote in message
...
On May 30, 1:16 am, "Graham Mayor" wrote:
I don't know much about programming Access tables, but the extraction of
the
data from the last column of the tables (no matter how many and how
organised) is simple enough. The following will do that - and here
displays
them table by table in a message box. Replace that message box with the
commands to send the content to your Access cell.

Dim oTable As Table
Dim oRow As Row
Dim oRng As Range
Dim sText As String
For Each oTable In ActiveDocument.Tables
sText = ""
For Each oRow In oTable.Rows
If oRow.Cells.Count 1 Then
Set oRng = oRow.Cells(oRow.Cells.Count).Range
oRng.End = oRng.End - 1
sText = sText & oRng.Text & Chr(44)
End If
Next oRow
sText = Left(sText, Len(sText) - 1)
MsgBox sText
'Insert sText into your table as required
Next oTable

Thanks, that is very helpful. But, in the Message Box I cannot see all
the contents
of all the columns of all tables in the document. I gather the CString
variable
should be able to store around 2^31 characters as it is a variable
string so it should
have enough capacity

Or, am I missing something else?

Thanks