簡體   English   中英

使用VBA將Excel中的圖表嵌入到Powerpoint中的指定占位符中

[英]Embedding a chart from Excel in a specified placeholder in Powerpoint using VBA

我正在嘗試將圖表從Excel電子表格復制到Powerpoint演示文稿中。 我已經有一個單獨的例程,可以打開PPT並導航到相關的幻燈片。

在幻燈片(2)上,我有一個占位符(形狀3),要在其中嵌入圖表,並保留指向Excel的鏈接。

運行代碼時,在執行的最后一行出現錯誤:“運行時錯誤'438':對象不支持此屬性或方法”。

代碼如下所示:

Sub MoveExcelObjectsToPresentation()

Set PPTapp = GetObject(, "PowerPoint.Application")

Set PPTpres = PPTapp.ActivePresentation

Dim waterfallChart As Chart

ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.ChartArea.Copy

PPTpres.Slides(2).Shapes(3).PasteSpecial '(DataType:=ppPasteOLEObject, Link:=msoTrue)


End Sub

謝謝!!

我仍然不知道最后一行代碼是什么問題,但是如果我用以下內容替換最后一行,則代碼可以正常工作:

With PPTpres
    .Slides(2).Shapes(8).Select
    .Windows(1).View.PasteSpecial (ppPasteMetaFile)
End With

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM