bobjohnson
12-04-2008, 03:51 PM
Hi,
I need to write a macro that replaces all graphics in a word document with text. The text will be the same no matter what graphic is replaced.
Originally i tried the code below, but i found that also will catch embedded excel files which I dont want. So i tried using the inlineshapes code but i cant figure out how to use that to delete the graphic and replace it with text at the same time. I got it to delete the graphic, or put some text after the graphic, but i cant get it to do both? Can anyone help?
This was my original code that would also catch embedded excel:
Sub replacegraphics()
Dim rng As Range
For Each rng In ActiveDocument.StoryRanges
Do
With rng.Find
.Text = "^g"
.Replacement.Text = "[graphic replaced]"
.Execute Replace:=wdReplaceAll
End With
Set rng = rng.NextStoryRange
Loop Until rng Is Nothing
Next rng
End Sub
I need to write a macro that replaces all graphics in a word document with text. The text will be the same no matter what graphic is replaced.
Originally i tried the code below, but i found that also will catch embedded excel files which I dont want. So i tried using the inlineshapes code but i cant figure out how to use that to delete the graphic and replace it with text at the same time. I got it to delete the graphic, or put some text after the graphic, but i cant get it to do both? Can anyone help?
This was my original code that would also catch embedded excel:
Sub replacegraphics()
Dim rng As Range
For Each rng In ActiveDocument.StoryRanges
Do
With rng.Find
.Text = "^g"
.Replacement.Text = "[graphic replaced]"
.Execute Replace:=wdReplaceAll
End With
Set rng = rng.NextStoryRange
Loop Until rng Is Nothing
Next rng
End Sub