Word to Excel
Hi Pepper,
To proccess all files in a folder, The Dir function is what you need.
To read word file,
1. make a reference to word in via VBA Tools/References
2. In word, a table can be refererd to by its index and the content using
row an column number
3. the sub
Sub WordToExcel()
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim x As Integer
Dim strFilename As String
Dim temp As String
Set wdApp = New Word.Application
'initialise counter
x = 1
'search for first file in directory
strFilename = Dir("C:/Temp/*.doc") 'amemd folder name
Do While strFilename < ""
Set wdDoc = wdApp.Documents.Open(strFilename)
temp = wdDoc.Tables(1).Cell(2, 1).Range.Text 'read word cell
Range("A2").Offset(x, 0) = temp
temp = wdDoc.Tables(1).Cell(2, 2).Range.Text 'read word cell
Range("A2").Offset(x, 1) = temp
'etc
wdDoc.Close
x = x + 1
strFilename = Dir
Loop
End Sub
--
Regards
Jean-Yves Tfelt
Europe
"Pepper" wrote:
Thank you Bob, my answer is both.
I am eager to learn VBA to help us automate Excel but right now my needs are
immediate. Any help with this project will be greatly appreciated.
Pepper
"Bob Bridges" wrote:
Hi, Pepper. Do you want to learn how to write a program like that, or just
have some code you can take and run? I'm a teach-a-man-to-fish kind of guy,
myself, so I offer the former, but if you prefer not to go to that kind of
trouble I'm sure there are others here (well, pretty sure) that'll just hand
you some code.
--- "Pepper" wrote:
...hundreds of Word file, containing a four-row, four-column table. I
need to have Excel look at each of these file and import into Excel
starting with the second row and including the third and fourth row.
It should continue until all the Word files have been processed.
|