VBA to align and resize picture in powerpoint

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
683
Office Version
  1. 2016
Platform
  1. Windows
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
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
any help with this would be much appreciated :)
 
Upvote 0

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top