I'm trying to copy ranges from an Excel sheet and paste them into slides as tables, then position and resize them. However, when I try to position the shapes in ppt, the .Left method doesn't behave as expected; in the slide thumbnails on the left of the screen the shapes are in the expected positions (centred as in the below code), but when I select the slide the shapes are shifted far to the right of where they ought to be.
I thought it may be using 'centre' as its reference point instead of the left bound of the slide but this doesn't match up with the amount it's offset.
Would really appreciate some help with this - would be good to know if it's a bug in ppt or an error in my code as if it's a bug it has a large impact on the feasibility of this project. For this particular example I could probably use the .Align method as a workaround but for later slides I need to be able to position multiple shapes on the same slide accurately.
I'm using Office 365.
Code below:
Sub PP_export()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim XLws As Worksheet
Set PPApp = New PowerPoint.Application
Set XLws = ActiveSheet
Set PPPres = PPApp.Presentations.Open("Y:\Research\PROJECTS\2018\Magic Macro\ppt_template_.potx")
PPApp.Visible = True
''Lifestyle Statements
'By Col%
Set PPSlide = PPPres.Slides(3)
Dim LSCol As PowerPoint.Shape
XLws.Range("M106:o126").Copy
PPSlide.Shapes.PasteSpecial ppPasteDefault
Set LSCol = PPSlide.Shapes("Table 2")
With LSCol
.Left = (28.35 * 10.56)
.Top = (28.35 * 3.83)
.Height = (28.35 * 13.21)
.Width = (28.35 * 12.75)
End With
'By Index
Set PPSlide = PPPres.Slides(4)
Dim LSIndex As PowerPoint.Shape
XLws.Range("Q106:s126").Copy
PPSlide.Shapes.PasteSpecial ppPasteDefault
Set LSIndex = PPSlide.Shapes("Table 2")
With LSIndex
.Left = (28.35 * 10.56)
.Top = (28.35 * 3.83)
.Height = (28.35 * 13.21)
.Width = (28.35 * 12.75)
End With
.Left=0
. – ashleedawg.Left
after you do so? – ashleedawgppPasteEnhancedMetafile
helps. – CCM