The current code below is a subroutine for an Excel to PowerPoint framework I am developing.
This works fine but I was just wondering if there was a way to either get the object number of the newly pasted object or to be able to label the object for manipulation(Instead of using the Object Number parameter).
For reference a typical line in the controller looks something like this:
Which copies the NamedGroupOfCharts, pastes them to slide 1 and is the 2nd object on the slide with a height of 73 points.
Thanks in Advance,
Jon Lorenzini
This works fine but I was just wondering if there was a way to either get the object number of the newly pasted object or to be able to label the object for manipulation(Instead of using the Object Number parameter).
For reference a typical line in the controller looks something like this:
Code:
Call CopyGroupPasteBitmap("NamedGroupOfCharts", 1, 2, , 73)
Which copies the NamedGroupOfCharts, pastes them to slide 1 and is the 2nd object on the slide with a height of 73 points.
Thanks in Advance,
Jon Lorenzini
Code:
Sub CopyGroupPasteBitmap(GroupName As String, SlideNumber As Integer, ObjectNumber As Integer, Optional Left As Variant, Optional Top As Variant, Optional Width As Variant, Optional Height As Variant)
'Makes the Correct Slide Active
Set PPT_Slide = PPT_File.Slides(SlideNumber)
'Copys Chart
ActiveSheet.Shapes.Range(Array(GroupName)).Select
Selection.Copy
'Pastes as Bitmap
With PPT_Slide
.Shapes.PasteSpecial DataType:=ppPasteBitmap, DisplayAsIcon:=msoTrue
End With
'Adjusts Height Width Left and Top per variables passed
With PPT_Slide.Shapes(ObjectNumber)
'Prevents Distortion of Images
.LockAspectRatio = msoTrue
'If there isn't a width variable then it sizes the width of Object to fit on PPT Slide
If IsMissing(Width) = True Then
.Width = (PPT_File.PageSetup.SlideWidth) - 20
Else
.Width = Width
End If
'If there isn't a height variable, it checks if it will go past the footer. If it is larger then it resizes it, otherwise it leaves it alone
If IsMissing(Height) = True Then
If PPT_Slide.Shapes(ObjectNumber).Height > (PPT_File.PageSetup.SlideHeight - Top - Footer) Then
.Height = (PPT_File.PageSetup.SlideHeight) - Top - Footer
Else
End If
Else
.Height = Height
End If
'If there isn't a left variable then it centers it on the PPT Slide
If IsMissing(Left) = True Then
.Left = (PPT_File.PageSetup.SlideWidth - .Width) / 2
Else
.Left = Left
End If
'If there isn't a top variable then it centers it on the PPT Slide
If IsMissing(Top) = True Then
.Top = (PPT_File.PageSetup.SlideHeight - .Height) / 2
Else
.Top = Top
End If
End With
End Sub