View Single Post
  #5   Report Post  
Doug Robbins
 
Posts: n/a
Default

Take a look at the thread "Extracting Text from Word Document" in the
microsoft.public.word.vba.general newsgroup:




--
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
"wjgaddis" wrote in message
...
I'm a novice programmer as well and can really use the code provided . . .
in
fact, I already have. However, I do get an error because the documents I
am
opening have tables instead of FormFields (not even sure what these are).
How do I extract data from a table?

"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?