PDA

View Full Version : Arrange Images relative to each other



c7015
05-24-2012, 10:39 AM
Hey Guys , I have a macro that pastes tables as images in a ppt like this

Dim Sh As Shape
Dim PP As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
Dim xlapp As Excel.Application
Dim opslide As PowerPoint.Slide
Dim shp As String

If optionbutton1.Value = True Then
xlapp.Range("a132:e142").Copy
PPpres.Slides(5).Shapes.PasteSpecial DataType:=ppPasteBitmap, link:=msoFalse

If optionbutton2.Value = True Then
xlapp.Range("a145:e152").Copy
PPpres.Slides(5).Shapes.PasteSpecial DataType:=ppPasteBitmap, link:=msoFalse

End If

If optionbutton3.Value = True Then
xlapp.Range("a154:e163").Copy
PPpres.Slides(5).Shapes.PasteSpecial DataType:=ppPasteBitmap, link:=msoFalse

End If

If optionbutton4.Value = True Then
xlapp.Range("a165:e172").Copy
PPpres.Slides(5).Shapes.PasteSpecial DataType:=ppPasteBitmap, link:=msoFalse

End If

If Optionbutton5.Value = True Then
xlapp.Range("a174:e178").Copy
PPpres.Slides(5).Shapes.PasteSpecial DataType:=ppPasteBitmap, link:=msoFalse

End If

If optionbutton6.Value = True Then
xlapp.Range("a180:e184").Copy
PPpres.Slides(5).Shapes.PasteSpecial DataType:=ppPasteBitmap, link:=msoFalse
End If



End If



so it selects which range based on what optionbutton is selected (really a check box but renamed)

the problem is it pastes them to the slide right in the center and I would like it to count how many pictures there are and arrange their position based on what it has counted.

I know I can move the pictures up and down with this code

Set oppslide = PPpres.Slides(5)
With oppslide
.Shapes("picture 2").IncrementTop -125
.Shapes("picture 3").IncrementTop 50
.Shapes("picture 4").IncrementTop 150
End With

but I cant figure out how to make it variable , as if there are only 3 pictures and not 4 it crashes because it cant find a "picture 4"

clear as mud ?

any insight or even off the wall ideas on how to do this would be great ?

Kenneth Hobs
05-24-2012, 11:04 AM
I don't like doing this but it might suffice.
On Error Resume Next

c7015
05-24-2012, 11:14 AM
I don't like doing this but it might suffice.
On Error Resume Next


I tried to have it count the pictures on the slide and if the value was X then
increment XXX
increment XXX
increment XXX

if the value was y then

increment XXX
increment XXX


and so on but my count images did not seem to want to work with my if then , no error thrown just nothing ..

I will try your solution as a last resort as it still does not solve my spacing problem ... because if there are only 2 images the spacing will be different then 4 so the incremental values will be variable depending on how many check boxes there are

c7015
05-24-2012, 11:17 AM
I know that "picture 2" is always going to be the top, can anyone think of a way to say "picture 3" increment("picture 2") 100

Kenneth Hobs
05-24-2012, 11:17 AM
Since this is the Excel forum, I would guess that all this happens in Excel. If you will post a simple Excel and PowerPoint file, I am sure that we can come up with a good solution.

You can probably do something like:
With oppslide
.Shapes("picture 2").IncrementTop .Shapes("picture 1").Top-125
End With