View Single Post
 
Old 12-10-2023, 01:11 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Then what about this:
Code:
Sub Test()

Dim oRng As range
Dim oRngD As range
Dim oRngDD As range
Dim vWd As Variant
Dim vHi As Variant
  
    Set oRng = ActiveDocument.range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "\<img width*\>"
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
        If .Execute Then
            Set oRngD = oRng.Duplicate
            Set oRngDD = oRng.Duplicate
            .text = "width=" & "[0-9]@ "
            .MatchWildcards = True
             If .Execute Then vWd = oRng
            With oRngD.Find
                .text = "height=" & "[0-9]@ "
                .MatchWildcards = True
                If .Execute Then  vHi = oRng
            End With
        End If
    End With
    oRngDD.Delete
MsgBox "'" & vWd & "'" & vbCr & "'" & vHi & "'"
lbl_Exit:
Set oRng = Nothing
Set oRngD = Nothing
Set oRngDD = Nothing
 End Sub
Notes:
1) Word & Height are remembered with trailing space, which I think is insignificant;
2) If you want to delete the final '<', change
.text = "\<img" & "*\>"
to
.text = "\<img" & "*\>\<"

Last edited by vivka; 12-10-2023 at 09:31 AM.
Reply With Quote