Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 3
Default Macro for copy Word into Excel

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
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.

  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
external usenet poster
 
Posts: 1
Default Macro for copy Word into Excel

On 9/10/05 3:37 PM, in article ,
"Gareth" 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Macro for copy Word into Excel

Hi Emile,

I think I pasted fcnGetFileList for you at the end of my post -- I
wouldn't be so mean not to!

I had a recursive one - that returned full paths for all files in
subfolders etc. I can't seem to put my hands on it and I don't have time
to rewrite it just now.

Here's one I found on google (from this NG) -- see bottom of email. Note
this isn't recursive but it should give the same results.

HTH,
Gareth

Bob Phillips Jul 25, 4:27 am show options

Newsgroups: microsoft.public.excel.programming
From: "Bob Phillips" - Find messages
by this author
Date: Mon, 25 Jul 2005 10:27:46 +0100
Local: Mon, Jul 25 2005 4:27 am
Subject: Recursive Function + File searching to return path
Reply to Author | Forward | Print | Individual Message | Show original |
Report Abuse

Straight-forward enough


Sub ph8()
Const sStartFolder As String = "c:\myTest"
Dim iCtr As Long
Dim iLevel As Long
Dim iBaseLevel As Long
Dim sh As Worksheet


iBaseLevel = Len(sStartFolder) - Len(Replace(sStartFolder, "\", ""))
With Application.FileSearch
.NewSearch
.LookIn = sStartFolder
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute 0 Then
On Error Resume Next
Set sh = Worksheets("Files")
On Error GoTo 0
If Not sh Is Nothing Then
sh.Cells.ClearContents
Else
Worksheets.Add.Name = "Files"
Set sh = ActiveSheet
End If
sh.Cells(1, 1) = sStartFolder
sh.Cells(1, 2) = 1
For iCtr = 1 To .FoundFiles.Count
iLevel = Len(.FoundFiles(iCtr)) - _
Len(Replace(.FoundFiles(iCtr), "\", ""))
sh.Cells(iCtr + 1, 1) = _
.FoundFiles(iCtr)
sh.Cells(iCtr + 1, 2).Value = iLevel
Next iCtr
End If
End With
End Sub





I used to have one somewhere....

Russs wrote:
On 9/10/05 3:37 PM, in article ,
"Gareth" 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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy from WORD to EXCEL using a macro..... Tee Excel Discussion (Misc queries) 1 March 1st 06 06:46 PM
Macro to copy a word doc into an excel doc Tee Excel Discussion (Misc queries) 0 February 22nd 06 12:01 PM
copy from Excel to Word by macro with certain for wmax77 Excel Discussion (Misc queries) 0 February 12th 06 11:33 AM
macro to copy in Excel and paste in Word? RockyDon Excel Programming 0 October 28th 04 11:59 PM
Copy/Paste From Excel To Word Macro Kris Taylor[_2_] Excel Programming 15 July 26th 04 02:27 PM


All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"