View Single Post
  #3  
Old 01-03-2019, 02:08 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,323
Default

In VBA your code could look similar to:
Code:
    Dim i1 As Long
    Dim search1 As String
    search1 = "NAME:"
    Dim i2 As Long
    Dim search2 As String
    search2 = "SURNAME:"
    
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
        .ClearFormatting
        .Wrap = wdFindStop
        .MatchCase = False
        .Text = search1
        .Execute
        Selection.Collapse Direction:=wdCollapseEnd
        i1 = Selection.End
        .Text = search2
        .Execute
        i2 = Selection.Start
    End With
    ActiveDocument.range(i1, i2).Copy
Only thing you need to do is some error handling (i2 > i1) and translating to Delphi
Reply With Quote