View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
Gareth[_6_] Gareth[_6_] is offline
external usenet poster
 
Posts: 158
Default Macro for copy Word into Excel

You need to open each word document, take the data and then close it.
Try something like:

Sub GoThroughWordDocs()

Dim myFiles As Variant
Dim oW As Object
Dim doc As Object

'Get list of document files from my path
myFiles = fcnGetFileList("c:\temp", "*.doc")

Set oW = GetObject(, "Word.Application")

If myFiles(LBound(myFiles)) = "" Then
MsgBox "no files found"
Exit Sub
End If

For i = LBound(myFiles) To UBound(myFiles)

'open the word document
Set doc = oW.Documents.Open(Filename:=myFiles(i))

'use whatever code you already have to prcoess
'this document

'close it
doc.Close

Next i

Set doc = Nothing
Set oW = Nothing

End Sub


HTH,
Gareth

emile wrote:
Hey guys,

I have been looking through past posts but can't really find what I am
looking for.

What I need is a macro that will take information within a certain table in
Word and transfer it into Excel. I have hundreds of Word documents on hand
and all are in a same format layuot. I will extract about 6 counts of
information and paste them into 6 columns of Excel, and the next Word
information will be pasted in the next row of Excel. Since the format of Word
will be the same, I was hoping that there can be a macro solution to this
problem.

I have already tried Macro recorder, but the recorded code will only target
Open documents and spreadsheets at a specific file name. Is it possible to do
all this without the hundreds of Word documetns opened?

I am new to macros so I really appreciate your help. Plus, if you have any
info about on-line tutorials of Word or Excel macros, please let me know.
That will help as well.

Thanks all.