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

Hi, RobiNew! Try this (perhaps, not the best method, but it works):
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 = oRngD
            End With
        End If
    End With
    oRngDD = "<img " & vWd & vHi & "img src=" & Chr(34) & "data:image/jpg;base64,"
    oRngDD.Collapse wdCollapseEnd
    oRngDD.InsertAfter Chr(34) & ">"
    oRngDD.Collapse
    oRngDD.InsertFile filename:="C:\E_DIME.txt", range:="", ConfirmConversions:= _
        False, Link:=False, Attachment:=False
lbl_Exit:
Set oRng = Nothing
Set oRngD = Nothing
Set oRngDD = Nothing
End Sub
Reply With Quote