Reformat & Combine Word Tables, Then Import Into Excel

B

Beirdo

I've got about 350 tables in Word. Each has 2 columns and 22 rows. I need
to import them into excel with 22 columns and 350 rows. The left column in
each Word table contains what will become the column title in excel. The
right column in each Word table contains what will become the data for each
record. Any help would be appreciated. Thanks
 
J

Joel

Sub GetTables()

FName = Application _
.GetOpenFilename("Word Files (*.doc), *.doc")

Set WordObject = GetObject(FName)

First = True
RowCount = 2
For Each Tble In WordObject.tables
For i = 1 To 22
If First = True Then
Data = Tble.Rows(i).Cells(1).Range
'Remove cell markers
Cells(1, i) = Left(Data, Len(Data) - 2)
End If
Data = Tble.Rows(i).Cells(2).Range.Text
'Remove cell markers
Cells(RowCount, i) = Left(Data, Len(Data) - 2)
Next i
RowCount = RowCount + 1
First = False
Next Tble
WordObject.Close savechanges = False
End Sub
 
B

Beirdo

Works like a charm. I thank you. My wife thanks you. Where can I learn
this stuff? Any recommendations for "Subject Matter Idiots"?
 

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