Thread: [Solved] VBA Picture Positioning
View Single Post
 
Old 09-20-2012, 04:10 AM
cole10 cole10 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2012
Posts: 3
cole10 is on a distinguished road
Question VBA Picture Positioning

I have a powerpoint slide that has 5 images on it. I have written a code that crops all images, resizes them and then aligns them centrally, but i want each image to be in the vertical position 100 points below the one above. Currently my code looks like this:

Sub CropResize()
Dim sldTemp As Slide
Dim lngTemp As Long
Dim lngCount As Long
For Each sldTemp In ActivePresentation.Slides
For lngCount = sldTemp.Shapes.Count To 1 Step -1
With sldTemp.Shapes(lngCount)
.PictureFormat.CropLeft = 100
.PictureFormat.CropTop = 55
.PictureFormat.CropRight = 70
.PictureFormat.CropBottom = 100
.LockAspectRatio = msoTrue
.Height = 100
.IncrementLeft 275
.IncrementTop 100

End With
Next
Next
Set screens = ActivePresentation.Slides(1)
screens.Shapes.Range.Align msoAlignCenters, msoTrue
End Sub


Which positions the top image perfectly, but i then want the one below to be at vertical position 100 + 100 and the third image to be 100 + 200 (ie 100 + image# x 100). I thought about using a 'for' function so for image 1 to 5 position is 100+image*100 type function but can't get it to work, it always comes up as an error. all help welcome please! (Sorry if i havent been clear!)
Reply With Quote