Hi, Vivka! I'm using your code, but I need your help once more. As you can see below, I added a few lines to your code, but I cannot achieve my aim, which is to insert the string |Chr(34) & ">"| after inserting text from a file.
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 & "'"
oRngDD.InsertAfter "<img " & vWd & vHi & "img src=" & Chr(34) & "data:image/jpg;base64,"
oRngDD.Collapse wdCollapseEnd
oRngDD.Select
oRngDD.InsertFile FileName:="C:\E_DIME.txt", Range:="", ConfirmConversions:= _
False, link:=False, Attachment:=False
'Here I need to insert the string |Chr(34) & ">"| at the end of the text received from the file.
'Can you help? Thanks!
'???Range???.InsertAfter Chr(34) & ">"
lbl_Exit:
Set oRng = Nothing
Set oRngD = Nothing
Set oRngDD = Nothing
End Sub