VBA: Copy survey word table to excel

Status
Not open for further replies.

Xlacs

Board Regular
Joined
Mar 31, 2021
Messages
105
Office Version
  1. 2016
Platform
  1. Windows
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!

QuestionsAgreeDisagreeNeutralStrongly 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
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Please posting the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

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