Word Form Data to Excel Worksheet

mikeannetta

New Member
Joined
Oct 6, 2015
Messages
13
Office Version
  1. 2019
Platform
  1. Windows
I see some old post to this for table data, but not form data.
I also have tried some of the internet solutions, the "closest solution" I saw for macro to do what I wanted was as follows, and for some unknown reason to me , its not working?
Error message is "Run-time Error '438': Object doesn't support this property or method.
It stops around Bolded / RED Texted area where it should pickup and open a word docx file? Anybody have an idea how to fix? I'll have about a 100 forms to get data from.....

Sub MM1GetFormData()


Application.ScreenUpdating = False
Dim wdApp As New Word.Application
Dim wdDoc As Word.Document
Dim FrFld As Word.FormField
Dim StrFolder As String, strfile As String
Dim WkSht As Worksheet, i As Long, j As Long
StrFolder = GetFolder
If StrFolder = "" Then Exit Sub
Set WkSht = ActiveSheet
i = WkSht.Cells(WkSht.Rows.Count, 1).End(xlUp).Row


'MAY NEED TO FIX FILE TYPE FROM DOCX to ???


strfile = Dir(StrFolder & "\*.docx", vbNormal)
While strfile <> ""
i = 1 + i
Set wdDoc = wdApp.Documents.Open(Filename:=StrFolder & "" & strfile, Addtorecentfiles:=False, Visible:=False)
With wdDoc
j = 0
For Each FmFld In .FormFields
j = j + 1
WkSht.Cells(i, j) = FmFld.Result

Next
End With

wdDoc.Close SaveChanges:=False
strfile = Dir()
Wend
wdApp.Quit

Set wdDoc = Nothing
Set wdApp = Nothing
Set WkSht = Nothing

Application.ScreenUpdating = False


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.Item.Path
Set oFolder = Nothing


End Function
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top