How to Extract key data from word
Hi,
I have a bunch of word documents/forms/questionnaires coming in and I would like to find a way to automate the extraction of several fields such as Name, Email, Company etc.
Unfortunately, the document wasn't created with this in mind so it doesn't have clear forms for the data-entered, e.g.
1. Company
Please indicate the company and provide contact details for the signatory on the contract.
Thanks very much.
Edit:
I tried a macro like this:
Sub DataExtract()
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oCell As Word.Cell
Dim sPath As String
Dim sFile As String
Dim r As Long
Dim c As Long
Dim Cnt As Long
Application.ScreenUpdating = False
Set oWord = CreateObject("Word.Application")
sPath = "H:\WordAccess" 'change the path accordingly
If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
sFile = Dir(sPath & "*.doc")
r = 2 'starting row
c = 1 'starting column
Cnt = 0
Do While Len(sFile) > 0
Cnt = Cnt + 1
Set oDoc = oWord.Documents.Open(sPath & sFile)
For Each oCell In oDoc.Tables(1).Range.Cells
Cells(r, c).Value = Replace(oCell.Range.Text, Chr(13) & Chr(7), "")
c = c + 1
Next oCell
oDoc.Close SaveChanges:=False
r = r + 1
c = 1
sFile = Dir
Loop
Application.ScreenUpdating = True
If Cnt = 0 Then
MsgBox "No Word documents were found...", vbExclamation
End If
End Sub
However it only extracts one of the tables in the document and I'm not sure how to customise that to the data I need.
|