Hello,
So I managed to identify all the word docs in a particular folder. However, I'm having a problem achieving to extract the 2nd column row 2 data of the table of all word docx.
Error: Set Table = doc.Table
" Object variable block"
The word table looks like the attached img. I only wanted to extract the "x" starting from row 2 column 2..
Hoping someone can actually help me on this.. Thank you in Advance!
So I managed to identify all the word docs in a particular folder. However, I'm having a problem achieving to extract the 2nd column row 2 data of the table of all word docx.
Error: Set Table = doc.Table
" Object variable block"
The word table looks like the attached img. I only wanted to extract the "x" starting from row 2 column 2..
Hoping someone can actually help me on this.. Thank you in Advance!
Questions | Agree | Disagree | Neutral |
What is... | x | ||
What is.. | x |
VBA Code:
Sub Open_Multiple_Word_Files(sPattern As String)
Dim shApp As Object
Dim shFolder As Object
Dim File, Files
Dim currentPath As String
Dim doc As Word.Document
Dim wd As New Word.Application
Dim sh As Worksheet
'get folder
Set shApp = CreateObject("shell.application")
folder2search = "C:\Users\ChrisLacs\Desktop\extrac\"
Set shFolder = shApp.Namespace(folder2search)
'get files
Set Files = shFolder.Items()
'check if file names match the pattern
For Each File In Files
If File.Name Like sPattern Then
Set Table = doc.Table
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row + 1
For i = 1 To 6
sh.Cells(lr, i).Value = Application.WorksheetFunction.Clean(Table(1).Rows(i).Cells(2).Range.Text)
Debug.Print File.Name & " - " & (File.Name Like sPattern)
Next
End If
Next File
End Sub
Sub Search_it()
Open_Multiple_Word_Files "Form*"
End Sub