There are going to be other methods but the below works for me, it will open a specific pptx file, add a slide, paste the selected/ active chart to that slide.
You may need to either edit the binding or add a reference to the PowerPoint object library in the VBE.
Sub ExportChartsToPowerPoint() Dim strPresPath As String Dim ppApp As PowerPoint.Application Dim myPres As PowerPoint.Presentation Dim sc As Integer strPresPath = "C:\Users\jbloggs\Desktop\test.pptx" Set ppApp = CreateObject("PowerPoint.Application") Set myPres = ppApp.Presentations.Open(strPresPath) sc = myPres.Slides.Count + 1 With ActiveChart .ChartArea.Copy myPres.Slides.AddSlide sc, myPres.SlideMaster.CustomLayouts.Item(7) myPres.Slides(sc).Select ppApp.ActiveWindow.View.Paste With myPres.Slides(sc).Shapes(1) .Left = 100 ' Adjust the left position as needed .Top = 100 ' Adjust the top position as needed .Width = 400 ' Adjust the width as needed .Height = 300 ' Adjust the height as needed End With End With End Sub




Reply With Quote
