D
David
Hi,
I'm trying to create a macro that finds and replaces words with
pictures (the words correspond to the filenames of pictures that are
saved in one directory).
Filenames are searched for, cut, then pasted into the "Insert Picture"
browser. The problem is that it inserts the same picture each time; I
want the FileName to equal the word that has been cut. Entire code is
pasted below.
Thanks in advance,
David
Selection.Find.ClearFormatting
With Selection.Find
.Text = "%%%"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.InlineShapes.AddPicture FileName:= _
"C:\My Documents\My Pictures\bonebrush.jpg", LinkToFile:=False,
_
SaveWithDocument:=True
End Sub
I'm trying to create a macro that finds and replaces words with
pictures (the words correspond to the filenames of pictures that are
saved in one directory).
Filenames are searched for, cut, then pasted into the "Insert Picture"
browser. The problem is that it inserts the same picture each time; I
want the FileName to equal the word that has been cut. Entire code is
pasted below.
Thanks in advance,
David
Selection.Find.ClearFormatting
With Selection.Find
.Text = "%%%"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.InlineShapes.AddPicture FileName:= _
"C:\My Documents\My Pictures\bonebrush.jpg", LinkToFile:=False,
_
SaveWithDocument:=True
End Sub