如果您想将 Excel 图表作为 Unliked 对象粘贴到 PowerPoint 中,但仍将其作为嵌入的 OLEObject 进行维护,我建议您将其粘贴为 OLEObject。粘贴看起来像这样:
'Create a new slide in the Presentation, set the layout to blank, and paste chart on to the newly added slide.
Set PPTSlide = PPTPres.Slides.Add(SldIndex, ppLayoutBlank)
PPTSlide.Shapes.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse
这是一些简单的代码,您可以在其中将多个图表粘贴到工作簿中,作为不带链接的 OLEObject 到 PowerPoint 演示文稿中。
Sub ExportChartsToPowerPoint_MultipleWorksheets()
' OVERVIEW:
' This script will loop through all the worksheets in the Active Workbook
' and copy all the Charts to a new PowerPoint presentation that we create.
' Each chart will get their own individual slide and will be placed in the center of it.
'Declare PowerPoint Variables
Dim PPTApp As PowerPoint.Application
Dim PPTPres As PowerPoint.Presentation
Dim PPTSlide As PowerPoint.Slide
Dim PPTShape As PowerPoint.Shape
Dim SldIndex As Integer
'Declare Excel Variables
Dim Chrt As ChartObject
Dim WrkSht As Worksheet
'Create new PowerPoint Application & make it visible.
Set PPTApp = New PowerPoint.Application
PPTApp.Visible = True
'Create new presentation in the PowerPoint application.
Set PPTPres = PPTApp.Presentations.Add
'Create an index handler for slide creation.
SldIndex = 1
'Loop throught all the Worksheets in the Worksheets Collection.
For Each WrkSht In Worksheets
'Loop through all the CHARTOBJECTS in the ACTIVESHEET.
For Each Chrt In WrkSht.ChartObjects
'Copy the Chart
Chrt.Chart.ChartArea.Copy
'Create a new slide in the Presentation, set the layout to blank, and paste chart on to the newly added slide.
Set PPTSlide = PPTPres.Slides.Add(SldIndex, ppLayoutBlank)
PPTSlide.Shapes.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse
'Increment index so that way we paste the next chart on the new slide that is added.
SldIndex = SldIndex + 1
Next Chrt
Next WrkSht
End Sub
现在,这实际上是我在我的一个 YouTube 视频中回顾的一些代码,所以如果你想浏览整个代码,我鼓励你访问下面的链接。
https://youtu.be/DOaBtYMCCEM
完全披露这是我的个人 YouTube 频道。