Hi,
I have a macro that copies a variable range in excel and pastes it as a picture into powerpoint.
I would like to change the code so the picture is aligned centre and middle and then resized (keeping it's ratio) to occupy a the majority of the slide (eg. 75% of the slide size which gives me space for slide headings, footnotes etc.). This resizing is key as the excel range may vary in height (see code). Put another way - I have a maximum space on the slide that I want the picture to occupy whatever the size of the copied range in excel.
Any thoughts greatly appreciated, many thanks.
Sub Macro11()
'
' Macro11 Macro
Sheet19.Select
Dim Shp As Object
Dim sld As Object
Dim eff As Object
Const msoAnimEffectFade As Long = 10
Const msoAnimTriggerWithPrevious As Long = 2
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
Range("G20:O20").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set sld = PPPres.Slides("Yourself")
Set Shp = sld.Shapes.Paste.Item(1)
Set eff = sld.TimeLine.MainSequence.AddEffect _
(Shape:=Shp, effectid:=msoAnimEffectFade, Trigger:=msoAnimTriggerWithPrevious) 'effect details
eff.Timing.Duration = 0.5
eff.Timing.TriggerDelayTime = 0
With Shp
.LockAspectRatio = msoTrue
.ScaleHeight 0.75, msoTrue
.Left = 21
.Top = 116
.ZOrder msoSendToBack
End With
End Sub
I have a macro that copies a variable range in excel and pastes it as a picture into powerpoint.
I would like to change the code so the picture is aligned centre and middle and then resized (keeping it's ratio) to occupy a the majority of the slide (eg. 75% of the slide size which gives me space for slide headings, footnotes etc.). This resizing is key as the excel range may vary in height (see code). Put another way - I have a maximum space on the slide that I want the picture to occupy whatever the size of the copied range in excel.
Any thoughts greatly appreciated, many thanks.
Sub Macro11()
'
' Macro11 Macro
Sheet19.Select
Dim Shp As Object
Dim sld As Object
Dim eff As Object
Const msoAnimEffectFade As Long = 10
Const msoAnimTriggerWithPrevious As Long = 2
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
Range("G20:O20").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set sld = PPPres.Slides("Yourself")
Set Shp = sld.Shapes.Paste.Item(1)
Set eff = sld.TimeLine.MainSequence.AddEffect _
(Shape:=Shp, effectid:=msoAnimEffectFade, Trigger:=msoAnimTriggerWithPrevious) 'effect details
eff.Timing.Duration = 0.5
eff.Timing.TriggerDelayTime = 0
With Shp
.LockAspectRatio = msoTrue
.ScaleHeight 0.75, msoTrue
.Left = 21
.Top = 116
.ZOrder msoSendToBack
End With
End Sub