Я записал макрос и немного изменил его, чтобы сделать его общим. Он делает то, что мне нужно. Вот сценарий:
Sub replace_path_with_image()
'
' replace_path_with_image Macro
'
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "c:\users"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EscapeKey
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Dim Sel As Selection
Set Sel = Application.Selection
Dim FilePath As String
If Sel.Type <> wdSelectionIP Then
FilePath = Sel.Text
End If
Selection.Cut
Selection.InlineShapes.AddPicture FileName:= _
FilePath _
, LinkToFile:=False, SaveWithDocument:=True
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub