hello everyone,
i dont have much knowledge in VBA, so i found a code that could help me with the work i am doing which is exporting data from word and putting in Excel. So i copied the code as explained in the tutorial but it keeps giving me this error. I will post the code and the tutorial Video if anyone can help me, it would be much appreciated.
https://www.youtube.com/watch?v=1x-Vk4Qmpz0
Sub GetFormData() Application.ScreenUpdating = False Dim wdApp As New Word.Application Dim wdDoc As Word.Document Dim FmFld 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 strFile = Dir(strFolder & "*.docx", vbNormal) While strFiled "" i = i + 1 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 strFiled = Dir() Wend wdApp.Quit Set wdDoc = Nothing: Set wdApp = Nothing: SetWkSht = 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