Hi, the following macro adds tags to image names, the problem is that if there are two or more instances of image names, the InsertBefore command does not add tags exactly in the right place. There is also a case-sensitive problem that does not work with wildcards. File attached below.
Sub JPG_xml()


                
    Dim fRng As Range
        Set fRng = ActiveDocument.Range
    With fRng.Find
         
        Do While .Execute(findText:="^13<*>.JPG", _
        MatchWholeWord:=True, MatchWildcards:=True, _
        MatchCase:=False)
     
  
            With fRng
                           
              .Start = fRng.Start + 1
                .InsertAfter """></Image>" & Chr(13)
                .InsertBefore "<Picture>" & Chr(13) & "<Image href=""file://images/"
                                  
               .Collapse 0
            End With
            
           'Exit Do
        Loop
    End With
    
lblx_Exit:
    Set fRng = Nothing
    End Sub
code add tags jpg.docx