Extract data from Word Table

C

Cliff

Hey all,

I have a large document with hundreds of word tables that I would like to
extract into Excel with VBA. The MSDN example I found doesn't work so I'm
not sure how to proceed.

I don't know the Word Object model at all so any pointers or URLs would be
greatly appreciated.

Thanks,
Cliff
 
F

fumei via OfficeKB.com

Perhaps if you gave a bit more detail on precisely what you want to do.

Also, perhaps give us reference to exactly what in MSDN you used, and found
did not work. We can maybe give more detail pointers to what will work.
 
C

Cliff

---More detail per request---

I have a Word document with about 75 tables with varying column numbers and
numbers of rows. Every table has the first row used for column headers.
Some tables span multiple pages. Some cell data is just a URL and some
cells have multiple bulleted or numbered lines. I wish to extract every row
in every column to an Excel file for further manipulation. There's a total
of about 1500 rows in all of the 75 tables.

This example below from MSDN generates an out of bounds error and j is never
defined or incremented.

http://msdn.microsoft.com/en-us/library/aa537149(office.11).aspx#officeworda
utomatingtablesdata_extractingdatafromatable

TIA,
Cliff
 
D

Doug Robbins - Word MVP

I would suggest that you show us the actual code that you tried to use.

How do you want the tables to be arranged in Excel? One Word table to a
worksheet? Or, all on one worksheet?

However, you don't need automation for this. Just use Ctrl+A, then Ctrl+C
in Word, then move to Excel and single cell selected, use Ctrl+V

It there is text between the tables that you don't want in Excel, run a
macro containing the following code to get rid of it:

Dim apara as Paragraph
For Each apara in ActiveDocument.Paragraphs
With apara.Range
If .Information(wdWithinTable) = False Then
.Delete
End If
End With
Next

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top