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

In VBA your code could look similar to:
    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
        .Wrap = wdFindStop
        .MatchCase = False
        .Text = search1
        Selection.Collapse Direction:=wdCollapseEnd
        i1 = Selection.End
        .Text = search2
        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