Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to import Word document tables into Excel

Status
Not open for further replies.

jimdurand

Technical User
Jan 20, 2010
4
AU
As most of you may or may not know, there is a bit of a trick to importing the contents of a Word table into Excel and have it formatted properly because of the paragraphs and line feeds.
We have hundreds of Word documents that should've been done in excel and now they want them converted.
I am currently writing a script that iterates through a directory and creates new excel docs from existing Word docs with tables. Completely formatted.

I have just completed that hardest part for me, the Word Model. That is why posted to this forum earlier.

I have used forums for years and I would love to be able to give something back.
If anyone thinks they have a need for this script I am happy to share it when I finish.
 
The problem I always find with Word documents is paragraph and table counting. Once you get the correct object, extracting the data is not a problem. The problem is locating the correct object. For instance, if you know that the table is always after the 3rd paragaraph after the word disaster, then it is not a problem; however, nothing ever runs smoothly and there will be one where it is either on the 2nd or 5th paragraph, at which point you go GNNNNN.

Also you have to make sure that it is a version of Word that uses VBA, not WordBasic (Word 97). This is normally only a problem on Windows 98 machines which, thankfully aren't that common nowadays.
 



Hi,

"Locating" tables is not a problem, because the Tables object is a collection of each Table. "Location" is irrelevant.

Please repost this question in forum707, where VBA coding questions can be properly addressed.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I now know what you are talking about XWB. I have been automating Excel for years and couldn't handle the fact that I couldn't just "Select" something in word to get my bearings.

That's what led me down the track of what Skip is talking about. I spent forever trying to get INTO the table, then I realized there must be a collection.

Our documents only have 1 table which made it easy. I just had to get my head around not being able to place my cursor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top