1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Sub copyChartToPPT()
Dim ChtObj As ChartObject
Dim PP As PowerPoint.Application
Dim PPpres As PowerPoint.Presentation
' Get chart object.
With ThisWorkbook.Sheets("STAT01")
Set ChtObj = .ChartObjects("Chart 1")
With ChtObj
.Copy
End With
'Create a PP application and make it visible.
Set PP = New PowerPoint.Application
PP.Visible = msoCTrue
'Open the presentation you wish to copy to.
Set PPpres = PP.Presentations.Open("W:\A\AMSR\Business\WISE\esg_portfolio_analytics\visualization\TMPL_EMBED.pptx")
'And paste it on the 1st slide.
'PP.ActiveWindow.View.PasteSpecial DataType:=ppPasteDefault
'PPpres.Slides(1).Shapes.PasteSpecial ppPasteDefault
'PPpres.Slides(1).Shapes.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse
'PP.ActiveWindow.View.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse
'PPpres.Slides(1).Shapes.PasteSpecial ppPasteOLEObject
PP.CommandBars.ExecuteMso "PasteExcelChartDestinationTheme"
'"PasteExcelChartSourceFormatting"
End With
Set PP = Nothing
Set PPpres = Nothing
End Sub |
Partager