Repeating (or Looping?) an Action with VBA in Word 2007

N

Nina

Hello,
I am very new to VBA. I am trying to create a macro for a Word 2007
document that finds a graphic, then resizes it to original size (Reset in
Format Picture dialog box). I have recorded the following, which produces
the result I want for one graphic. How do I make it loop so that it will
perform the action on ALL the graphics in my document? When responding,
please keep in mind that I am a novice with VBA. :)

Sub ResizeSlide()
'
' ResizeSlide Macro
'
'
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
WordBasic.FormatPicture SetSize:=0, CropLeft:="0", CropRight:="0",
CropTop _
:="0", CropBottom:="0", ScaleX:=100, ScaleY:=100, SizeX:="5",
SizeY:= _
"3.75"
End Sub
 
D

Doug Robbins - Word MVP

Try:

Dim i As Long
With ActiveDocument
For i = 1 To .InlineShapes.Count
With .InlineShapes(i)
.ScaleHeight = 100
.ScaleWidth = 100
End With
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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