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 ?
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 ?