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

Re: Extract data from Word Table by Doug

Doug
Sun May 11 04:28:35 PDT 2008

See the article "Control Word from Excel" at:

http://www.word.mvps.org/FAQs/InterDev/ControlWordFromXL.htm




--
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

"Cliff" <rcbuetikofer@comcast.net> wrote in message
news:C44C4EA7.5DF%rcbuetikofer@comcast.net...
> 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
>
>



Re: Extract data from Word Table by fumei

fumei
Sun May 11 14:02:26 PDT 2008

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.


Cliff wrote:
>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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200805/1


Re: Extract data from Word Table by Cliff

Cliff
Sun May 11 18:23:24 PDT 2008

---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





On 5/11/08 5:02 PM, in article 8402484772789@uwe, "fumei via OfficeKB.com"
<u37563@uwe> wrote:

> 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.
>
>
> Cliff wrote:
>> 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


Re: Extract data from Word Table by Doug

Doug
Sun May 11 20:41:03 PDT 2008

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

"Cliff" <rcbuetikofer@comcast.net> wrote in message
news:C44D144C.5FE%rcbuetikofer@comcast.net...
> ---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
>
>
>
>
>
> On 5/11/08 5:02 PM, in article 8402484772789@uwe, "fumei via OfficeKB.com"
> <u37563@uwe> wrote:
>
>> 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.
>>
>>
>> Cliff wrote:
>>> 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
>



Re: Extract data from Word Table by Cliff

Cliff
Mon May 12 16:07:27 PDT 2008

Thanks Doug, I'll give this a try.

Cliff


On 5/11/08 11:41 PM, in article empLGI#sIHA.2292@TK2MSFTNGP03.phx.gbl, "Doug
Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote:

> 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