View Single Post
 
Old 01-01-2024, 12:54 PM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Hi, RobiNew! Try this:
Code:
Sub MovingChr()
Set oRng = ActiveDocument.range
    With oRng.Find
    .text = "<p class=MyPar>"
    .Execute
    End With
    If oRng.Characters.Last.Next Like "<" Then
        oRng.MoveEnd unit:=wdCharacter, count:=1
        oRng.MoveEndUntil Cset:="<"
        oRng.Collapse wdcollapsend
        oRng.Select 'to see the cursor psn; if you are going to work with oRng, this line can be deleted
    End If
End Sub
or this:

Code:
Sub MovingChr()
Set oRng = ActiveDocument.range
    With oRng.Find
    .text = "<p class=MyPar>"
    .Execute
    End With
    oRng.Collapse wdcollapsend
    If oRng.Characters.First Like "<" Then
        oRng.Move unit:=wdCharacter, count:=1
        oRng.MoveUntil Cset:="<"
        oRng.Select 'to see the cursor psn; if you are going to work with oRng, this line can be deleted
    End If
End Sub
Reply With Quote