tags:

views:

68

answers:

1

I have an MS Word 2003 file which contains several tables in it and I want to extract a specific table contents. For example, tables will be coming under some sections and I want to extract the contents of the table that are coming under section 6 alone and no other table contents, I want copy those contents to an new Excel sheet with formatting.

SECTION 4
Table data
Table data
Table data

SECTION 5
Table data
Table data
Table data

SECTION 6
Table data # TABLE DATA TO BE EXTRACTED AND IMPORTED TO AN NEW EXCEL SHEET
Table data # TABLE DATA TO BE EXTRACTED AND IMPORTED TO AN NEW EXCEL SHEET
Table data # TABLE DATA TO BE EXTRACTED AND IMPORTED TO AN NEW EXCEL SHEET

SECTION 7
Table data
Table data
Table data

+2  A: 

Unless you are thinking of using something like antiword, your starting point is the Perl module Win32::OLE, which is installed as part of ActiveState Perl. You need to start a Microsoft Word application using OLE, open your document, then look at the Sections object of the document object, find the Section object which is your section six, then look at the Tables property of the Range property of the Section object, and find the Table object you want in it.

Copying to an Excel sheet involves something similar.

It's difficult to write a code example unless I have a document to work with, so I'm not even going to attempt that.

Kinopiko
hi thanks for supporting me.. by the way when i went through the OLE section and i got an idea that SECTIONS can be greped using paragraphhs->{Text} object but i dint get any idea how to find out the exact table under this section please help...
jack
@jack: if you have another question, can you ask it separately as a new question? It's really difficult to have a conversation using these comment boxes. Also, my recommendation for your new question is that it's best if you show some codes you have written so far.
Kinopiko
hi is it possible in VBA? if so i will post the same question using VBA instead of perl
jack