From: emile on
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.
From: Gareth on
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.
From: Russs on
On 9/10/05 3:37 PM, in article OyYHo8jtFHA.2792(a)tk2msftngp13.phx.gbl,
"Gareth" <msng(a)garhooREMOVEME.com> wrote:

> 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.
Hi Gareth,
I did a google search to find 'fcnGetFileList' and found it OK. Is there a
function using VBA to recursively process all files in a given directory and
all the directory's subdirectories?
--
Russs

drsmN0SPAMikleAThotmailD0Tcom.INVALID <-- fix this before replying