Hello,
Below I have the following code to copy and paste to from Excel to PowerPoint as Bitmap.
What I want to do now is that, how do I make the chart to centre horizontally.
As well, notice that I have make the height to change first, so that the width of the chart is 'automatically resize as well due to the "LockAspectRatio"
Set ppSlide = myPresentation.Slides(8)
Sheets("PPT-page8").Range("A1:Z26").Copy
ppSlide.Shapes.PasteSpecial (ppPasteBitmap)
PowerPointApp.ActiveWindow.Selection.ShapeRange.LockAspectRatio = True
PowerPointApp.ActiveWindow.Selection.ShapeRange.Height = 329.76
PowerPointApp.ActiveWindow.Selection.ShapeRange.Left = AUTOMATICALLY CENTRE HORIZONTALLY
PowerPointApp.ActiveWindow.Selection.ShapeRange.Top = 72
I googled and was able to find a 'solution', but no matter how I try to incorporate it, it doesn't work.
'Center the Object Horizontally and Vertically
With ActivePresentation.PageSetup
Obj_Left = Obj.Left
Obj_Top = Obj.Top
'Center Horizontally
Obj.Left = (.SlideWidth \ 2) - (Obj.Width \ 2)
'Center Vertically
Obj.Top = (.SlideHeight \ 2) - (Obj.Height \ 2)
End With
Given that my width is automatically resize, will the above code 'Obj.Width' be able to capture the 'latest' width once the PowerPointApp.ActiveWindow.Selection.ShapeRange.Height = 329.76 is set?
PS: Macro is ran on Excel and not in PowerPoint
Bookmarks