Find and replace graphics.

D

Dragoncity

Hi,
I'm very new to macros and VBA, and need help.

I need to replace all the graphics in a Word document using Paste Special so
they are converted from HTML linked images to embedded images.

I have recorded the macro to do this, but I want the whole action to repeat
(find graphic, cut, paste, move to next graphic)

I have tried to look at the samples available, but I'm WAAAAY above my head
on this. Any help would be just peachy :)

My current macro is:

Sub ChangeImage()
'
' ChangeImage Macro
' Macro recorded 27/10/06 by Nicola Harlow
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Cut
Selection.PasteSpecial Link:=False, DataType:=wdPasteOLEObject,
Placement _
:=wdInLine, DisplayAsIcon:=False
End Sub

I've tried Repeat, but that just re-does the paste. Not useful.

Thanks,

Nicola :)
 
G

Graham Mayor

Am I missing something here - will CTRL+A - then - CTRL+SHIFT+F9 not do what
you want?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Dragoncity

My bad, should have tried it first.

That's a great shortcut, thanks! I converts them easily :)

Thank you so much, that's saved me a lot of hassle!

Nicola
 
D

Dragoncity

Sorry, after investigation I discovered that it removed all of the hyperlinks
as well. Although having hyperlinks in Word is not ideal, it's better than
nothing!

So I still need to find a way of repeating the code down the document.
Suggestions? Ta.
 
D

Dave Lett

Hi,

Does the following meet your needs?

Dim iFld As Integer

For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldIncludePicture Then
.Unlink
End If
End With
Next iFld

HTH,

Dave
 
D

Dragoncity

Perfect, thanks! :)

Nicola

Dave Lett said:
Hi,

Does the following meet your needs?

Dim iFld As Integer

For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldIncludePicture Then
.Unlink
End If
End With
Next iFld

HTH,

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top