Extract Data from Word Document Using Word and Excel VBA @Exceltrainingvideos
Extract Data from Word Document Using Word and Excel VBA  @Exceltrainingvideos
Uploaded July 2020 | Updated September 2026, 1 week ago
How to extract data from a Word document using both Word VBA and Excel VBA.
Here's the complete code:
Sub ExtractText()
Dim cDoc As Word.Document
Dim cRng As Word.Range
Dim i As Long
i = 2

Dim wordapp As Object
Set wordapp = CreateObject("word.Application")
wordapp.Documents.Open "c:\bracketdata\bracket-data.docx"
wordapp.Visible = True

Set cDoc = ActiveDocument
Set cRng = cDoc.Content

With cRng.Find
.Forward = True
.Text = "["
.Wrap = wdFindStop
.Execute
Do While .Found
'Collapses a range or selection to the starting or ending position
cRng.Collapse Word.WdCollapseDirection.wdCollapseEnd
cRng.MoveEndUntil Cset:="]"
Cells(i, 1) = cRng
cRng.Collapse Word.WdCollapseDirection.wdCollapseEnd
.Execute
i = i + 1
Loop
End With
wordapp.Quit
Set wordapp = Nothing

End Sub

Option Explicit

Sub ExtractText()
Dim cDoc As Word.Document, nDoc As Word.Document
Dim cRng As Word.Range, nRng As Word.Range

Set cDoc = ActiveDocument
Set nDoc = Documents.Add

Set cRng = cDoc.Content
Set nRng = nDoc.Content

cRng.Find.ClearFormatting
With cRng.Find
.Forward = True
.Text = "["
.Wrap = wdFindStop
.Execute
Do While .Found
cRng.Collapse Word.WdCollapseDirection.wdCollapseEnd
cRng.MoveEndUntil Cset:="]", Count:=Word.wdForward

nRng.FormattedText = cRng.FormattedText
nRng.InsertParagraphAfter
nRng.Collapse Word.WdCollapseDirection.wdCollapseEnd
cRng.Collapse Word.WdCollapseDirection.wdCollapseEnd
.Execute
Loop
End With
End Sub

Reference:
social.msdn.microsoft.com/Forums/en-US/bbdc6c84-240e-43e1-aec9-402ca60c0c84/macro-code-help-extracting-text-between-brackets-from-word-file-into-a-new-file
Extract Data from Word Document Using Word and Excel VBACalendar Control for All Office versionsFilter Data into Listbox using two Combo-boxes data as CriteriaAutomatically Pop-Up Find Dialog BoxSort Worksheet Tabs By ColorGenerate Random Strings in Excel with VBADisplay Data in Listbox based on Combo Box SelectionCreate Floating ButtonForward Message via whatsapp DesktopSpeed Up MacrosPrevent Users From Pasting Data into Text Boxes on UserFormUsing Excel VBA to Create Reciprocal Formulas
Dinesh Kumar Takyar |

Extract Data from Word Document Using Word and Excel VBA

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER