For some macros that show how you might go about this for a single document, see:
https://www.msofficeforums.com/word-...acters-up.html
https://www.msofficeforums.com/word/...doc-excel.html
For code demonstrating how to process an entire folder and export Word data to Excel, see:
https://www.msofficeforums.com/word-...html#post64259
If your data are held in formfields or content controls, the following
Excel macro might be more useful. It extracts data from all formfields & content controls in all Word documents in the selected folder and populates the first available row in the active Excel worksheet with the data for each document.
Code:
Sub GetFormData()
'Note: this code requires a reference to the Word object model.
'See under the VBE's Tools|References.
Application.ScreenUpdating = False
Dim wdApp As New Word.Application, wdDoc As Word.Document
Dim FmFld As Word.FormField, CCtrl As Word.ContentControl
Dim strFolder As String, strFile As String
Dim WkSht As Worksheet, c As Long, r As Long
strFolder = GetFolder
If strFolder = "" Then Exit Sub
Set WkSht = ActiveSheet
r = WkSht.Cells(WkSht.Rows.Count, 1).End(xlUp).Row
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
r = r + 1
Set wdDoc = wdApp.Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
c = 0
For Each FmFld In .FormFields
c = c + 1
With FmFld
Select Case .Type
Case Is = wdFieldFormCheckBox
WkSht.Cells(r, c) = .CheckBox.Value
Case Else
WkSht.Cells(r, c) = .Result
End Select
End With
Next
For Each CCtrl In .ContentControls
c = c + 1
With CCtrl
Select Case .Type
Case Is = wdContentControlCheckBox
WkSht.Cells(r, c) = .Checked
Case wdContentControlDate, wdContentControlDropdownList, wdContentControlRichText, wdContentControlText
WkSht.Cells(r, c) = .Range.Text
Case Else
End Select
End With
Next
.Close SaveChanges:=False
End With
strFile = Dir()
Wend
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
If you want to record the document's name as part of the data, change:
c = 0
to:
c = 1: WkSht.Cells(r, c) = strFile