Prev: page number
Next: send and close
From: Nina on 26 Feb 2010 10:41 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
From: Doug Robbins - Word MVP on 26 Feb 2010 15:43 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 "Nina" <Nina(a)discussions.microsoft.com> wrote in message news:5F64C183-880F-4546-9A12-2769F22FEADB(a)microsoft.com... > 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 >
From: Nina on 26 Feb 2010 16:49 Wow! This worked beautifully! Thank you so much! "Doug Robbins - Word MVP" wrote: > 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 > > "Nina" <Nina(a)discussions.microsoft.com> wrote in message > news:5F64C183-880F-4546-9A12-2769F22FEADB(a)microsoft.com... > > 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 > >
|
Pages: 1 Prev: page number Next: send and close |