converting word tables to excel

  • Thread starter Thread starter Eckard Buchner
  • Start date Start date
E

Eckard Buchner

I have a document that describes a new piece of software. The cost for each
feature is described in a word table. I would like to extract these tables
(with a makro?) into an excel sheet automatically. Any ideas anybody?

Eckard
 
If this is a one-time task, you can open the Word document, copy the
table, and paste it into Excel.
 
No, it's not a one time task. The specifiaction document is reviewed several
times. This leads to changes in the cost estimates. So I would have to paste
a dozen or so tables into excel againa and again.

My idea was to open a word document from excel (how?), extract the table
objects from the document structure (again, how?) and then populate an excel
sheet with the columns and rows of these tables. I'm not a makro expert. If
someone could give me a hint...

Thanks
Eckard
 
If you don't get a workable answer, you may want to post the question in a Word
newsgroup.

In fact, to me, this looks like a reasonable candidate for
cross-posting--including both an excel newsgroup and a word newsgroup in the
headers and sending once.
 
Thank you Dave, good idea. I got help in a word newsgroup. Here is the
current version of my macro (raw as it is).
Maybe, Debra, you have a look and add this to your great excel pages?

Thanks
Eckard

' ------------------------------
Sub ImportDoc()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdTable As Word.Table
Dim wdRow As Word.Row
Dim wdCell As Word.Cell
Dim nRow, nCol, nTab
Dim bHeader As Boolean

Set wdApp = New Word.Application
Set wdDoc =
wdApp.Documents.Open(FileName:="K:\Projekte\SironWeb\TDI-Integration\SironWe
b Integration TDI.doc")
wdApp.Visible = True
'Call or insert your table copying code here

Range("A1:E999").Clear

nTab = 1
nRow = 1

For Each wdTable In wdDoc.tables

nTab = nTab + 1
bHeader = True

For Each wdRow In wdTable.rows
nCol = 1
nRow = nRow + 1
For Each wdCell In wdRow.cells
nCol = nCol + 1


With ActiveSheet.cells(nRow, nCol)
.Select
.Font.Bold = bHeader
If bHeader Then
.HorizontalAlignment = xlCenter
Else
.HorizontalAlignment = xlHAlignGeneral
End If
End With

wdCell.Range.Copy
ActiveSheet.Paste

Next
bHeader = False
Next
nRow = nRow + 1
Next


'wdApp.ActiveDocument.Save
'wdApp.ActiveDocument.Close
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
End Sub
 
Even if Deb doesn't add this to her pages, it's now on google.

So lots of people can find it.



Eckard said:
Thank you Dave, good idea. I got help in a word newsgroup. Here is the
current version of my macro (raw as it is).
Maybe, Debra, you have a look and add this to your great excel pages?

Thanks
Eckard
<<snipped>>
 
Back
Top