Dear all,
I found a working code which has been made a long time ago - thanks to AlphaFrog.
However, this code pastes the charts as a picture. I want the charts to be pasted with the option "Keep source formatting & embed workbook" in the PowerPoint slides.
I believe I need this piece of code, but I don't know how to integrate it in the current one:
Can any of you help me out?
I found a working code which has been made a long time ago - thanks to AlphaFrog.
However, this code pastes the charts as a picture. I want the charts to be pasted with the option "Keep source formatting & embed workbook" in the PowerPoint slides.
Code:
Sub ChartToPresentation()
' Uses Early Binding to the PowerPoint Object Model
' Set a VBE reference to Microsoft PowerPoint Object Library
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
'Copy "Chart 1" on "Sheet1" to Slide # 2
' Copy "Chart 1" on "Sheet1" as a picture
ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart 1").CopyPicture
' Paste chart to Slide # 2
With PPPres.Slides(2).Shapes.Paste
' Align pasted chart
.Align msoAlignCenters, True
.Align msoAlignMiddles, True
End With
'Copy "Chart 1" to from "Sheet3" to Slide # 4
' Copy "Chart 1" on "Sheet3" as a picture
ActiveWorkbook.Sheets("Sheet3").ChartObjects("Chart 1").CopyPicture
' Paste chart to Slide # 4
With PPPres.Slides(4).Shapes.Paste
' Align pasted chart
.Align msoAlignCenters, True
.Align msoAlignMiddles, True
End With
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
I believe I need this piece of code, but I don't know how to integrate it in the current one:
Code:
PPTApp.CommandBars.ExecuteMso "PasteExcelChartSourceFormatting"
Can any of you help me out?