View Single Post
 
Old 12-09-2023, 09:46 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default

I managed to make it work correctly, provisionally on a single instance of the text mentioned above.
Perhaps someone can make it less clumsy.
Code:
Sub ThreeStrings()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
        .Text = "<img width"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = False
While .Execute
oRng.MoveEndUntil Cset:="><"
VarStrg1 = oRng
'MsgBox VarStrg1
oRng.Collapse
oRng.MoveEndUntil Cset:=" "
oRng.Move Unit:=wdCharacter, Count:=2
oRng.MoveEndUntil Cset:=" "
VarWd = oRng
'MsgBox VarWd
oRng.Move Unit:=wdCharacter, Count:=2
oRng.MoveEndUntil Cset:=" "
VarHi = oRng
'MsgBox VarHi
Set oRng = ActiveDocument.Range
With oRng.Find
        .Text = "<img width"
        .Replacement.Text = ""
        .Forward = False
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = False
        .Execute
End With
oRng.MoveEndUntil Cset:="><"
oRng.Delete
Goto End
Wend
    End With
End:
End Sub
Reply With Quote