Using VBA to extract all non image Word document content to excel

Chixoy

New Member
Joined
Dec 1, 2016
Messages
1
Hi,

I have ~350 Word documents and I need to extract the contents of each of them to excel (I can sort it out once it gets to excel). I have managed to extract the tables (see below) but I now need to extract the paragraphs as well. I'm hoping this is very easy modification, but I am struggling a bit as I'm new to VB. Any help would be appreciated. This is what I have so far and it works fine.. as far as tables are concerned

xl.Workbooks.Add
xl.Visible = True


'Here put your path where you have your documents to read:
myPath = "C:\temp\george4" 'End with '\'
myFile = Dir(myPath & "*.doc")
z = 1
xlRow = 1
Do While myFile <> ""
Documents.Open myPath & myFile
If ActiveDocument.Tables.Count < 3 Then
MsgBox ("Non standard layout @ " & z)
Else
For Each t In ActiveDocument.Tables
For Each r In t.Rows
xlCol = 1
For Each c In r.Range.Cells
myText = c.Range.Text
myText = Replace(myText, Chr(13), "")
myText = Replace(myText, Chr(7), "")
xl.ActiveWorkbook.ActiveSheet.Cells(xlRow, xlCol) = myText
xlCol = xlCol + 1
Next c
xl.ActiveWorkbook.ActiveSheet.Cells(xlRow, xlCol + 1) = myFile
xlRow = xlRow + 1
Next r
xlRow = xlRow + 1
Next t
End If
ActiveWindow.Close False
myFile = Dir
z = z + 1
Loop


End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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