vba to align picture centre and middle on powerpoint slide

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
683
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I have some code below that takes a range in Excel and copies it as a picture into Powerpoint. The bottom section of the code sizes and positions the picture on the ppt slide. How can I change the code so the picture is aligned centre and middle on the slide?
Hope you can help, many thanks.


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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
ok, have sussed it...

With Shp
.LockAspectRatio = msoTrue
.ScaleHeight 0.75, msoTrue
sngDefaultSlideWidth = PPPres.PageSetup.SlideWidth
sngDefaultSlideHeight = PPPres.PageSetup.SlideHeight
.Left = (sngDefaultSlideWidth - .Width) / 2
.Top = (sngDefaultSlideHeight - .Height) / 2
.ZOrder msoSendToBack
End With
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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