我有一些代碼需要excel中的圖表並將其粘貼到powerpoint幻燈片中。但是,一旦它被粘貼到powerpoint我不知道如何調整圖表大小。我研究過查找哪個數字是「形狀」,我可以手動執行此操作,但我不知道如何自動執行此操作。任何幫助將不勝感激,謝謝!從excel中插入後在powerpoint中調整圖表(Excel VBA)
這裏是我的代碼:
Sub AddChartToPPT(PPT As PowerPoint.Application, Slide As Integer, Chart As String, FromTop As Double, FromLeft As Double, Length As Double, Width As Double)
Dim activeslide As PowerPoint.Slide
PPT.ActiveWindow.View.GotoSlide Slide
Set activeslide = PPT.ActivePresentation.Slides(Slide)
ActiveSheet.ChartObjects(Chart).Activate
ActiveChart.ChartArea.Copy
activeslide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select
PPT.ActiveWindow.Selection.ShapeRange.Left = FromLeft
PPT.ActiveWindow.Selection.ShapeRange.Top = FromTop
'Need to add scaling code
End Sub
嗯,這似乎不工作。此外,您的代碼似乎是針對圖表的位置(我已經擁有),而不是圖表的大小。 – Andrew
使用.width和.height – nutsch
什麼似乎不起作用?你有錯誤信息嗎? – nutsch