View Single Post
 
Old 10-10-2017, 07:56 AM
edwinm edwinm is offline Windows 10 Office 2016
Novice
 
Join Date: Aug 2017
Posts: 9
edwinm is on a distinguished road
Default How to Select text between Chapters

Hello,

I need to select (and later on copy to other document) all the content between the Chapters 1.2 and 1.3.

I've tried this but need some help to fix this, can someone help me on this?
Thanks!


Sub test()
'Select tekst between Chapter 1.2 and 1.3
Set WDoc = ActiveDocument
For Each docfield In WDoc.Fields
Select Case docfield.Type
Case 88
Set objRange = docfield.Result
'Set Start en end for selection
If Left(objRange.Text, 3) = "1.2" Then Set TStart = objRange.Range
If Left(objRange.Text, 3) = "1.3" Then Set TEnd = objRange.Range
End Select
Next
WDoc.Range(TStart.Start, TEnd.End).Select
MsgBox "Done"
Set WDoc = Nothing

End Sub
Reply With Quote