View Single Post
  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Julie Julie is offline
external usenet poster
 
Posts: 57
Default extract data from multiple Word forms into Excel

Doug:
Thanks for the post. I ran your macro, but saved the result as a text file,
then imported it into an Access table. Works great!
--
Julie


"Doug Robbins" wrote:

If you put all of the documents into a folder by themselves and then run the
following macro, selecting that folder when prompted to do so, it should
create a new document with a paragraph for each of the documents containing
the data from the formfields with each piece of data separated by a tab.

You can then copy and paste that information into Excel.

Dim mydoc As Document
Dim target As Document
Dim i As Long

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path
Set target = Documents.Add
If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Set mydoc = Documents.Open(MyPath & MyName)
For i = 1 To mydoc.FormFields.Count - 1
target.Range.InsertAfter mydoc.FormFields(i).result & vbTab
Next i
target.Range.InsertAfter mydoc.FormFields(i).result & vbCr
mydoc.Close wdDoNotSaveChanges
MyName = Dir$
Loop

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"bbbitt" wrote in message
...
I have forms that have been filled out in Microsoft Word 2000. I would
like
to extract the data from all the forms in a folder and put it in a single
Excel spreadsheet. Can it be done?