Hi Good People,
I'm having a hard timing fixing the below code.
My problem is I wanted to extract a multiple survey answer in ms word table..
The below code extract only a single word file. I wanted to extract all the docx with file name Form* (e.g. Form 1,Form2, FOrm 3, etc.)
The word table looks like the below. I only wanted to extract the "x" starting from row 2 column 2..
Hoping someon can actually help me on this.. Thank you in Advance!
I'm having a hard timing fixing the below code.
My problem is I wanted to extract a multiple survey answer in ms word table..
The below code extract only a single word file. I wanted to extract all the docx with file name Form* (e.g. Form 1,Form2, FOrm 3, etc.)
The word table looks like the below. I only wanted to extract the "x" starting from row 2 column 2..
Hoping someon 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 extractData()
Dim wd As New Word.Application
Dim doc As Word.Document
Dim sh As Worksheet
wd.Visible = True
Set doc = wd.Documents.Open(ActiveWorkbook.Path & "\Form.docx")
Set tbls = doc.Tables
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)
Next
doc.Close
wd.Quit
Set doc = Nothing
Set sh = Nothing
Set wd = Nothing
End Sub