I managed to identify all th word docs. However, I'm having a problem achieving to extract the 2nd column row 2 data of the table.
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!
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 | Strongly Disagree |
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
Dim Tbls As Range
'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 Tbls = 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(Tbls(1).Rows(i).Cells(2).Range.Text)
Debug.Print File.Name & " - " & (File.Name Like sPattern)
Next
End If
Next File
End Sub