![](/img/trans.png)
[英]Resizing chart in powerpoint after inserting it from excel (Excel VBA)
[英]Resizing Excel Chart Using VBA in Powerpoint
我知道以前曾有人問過這個問題,但由於我不是VBA專家,所以我似乎無法獲得適用於我的特定方案的任何解決方案,因此我希望有人可以提供幫助。
我有一些VBA代碼,可從Excel復制選擇內容,基於模板打開新的PowerPoint演示文稿,然后將數據粘貼到PowerPoint的幻燈片2中。
我現在要做的唯一一件事就是操縱圖表的大小和位置。 為了實現這一點,我需要在下面的代碼中添加些什么?
'Opens a new PowerPoint presentation based on template and pastes data into Slide 2 of Powerpoint from Excel
Dim PPapp As PowerPoint.Application, PPpres As PowerPoint.Presentation, PPslide As PowerPoint.Slide
Dim XLws As Worksheet
Set XLws = ActiveSheet
Set PPapp = New PowerPoint.Application
Set PPpres = PPapp.Presentations.Open("C:\Users\Colin\Dropbox (Edge45)\Edge45 Team Folder\Edge45 Company Documents\Templates\Powerpoint Templates\Edge45 Audit Template Macro.potm", Untitled:=msoTrue)
PPapp.Visible = True
Set PPslide = PPpres.Slides(2)
XLws.Range("A1:D16").Copy
PPslide.Shapes.PasteSpecial DataType:=ppPasteHTML, Link:=msoFalse
Application.CutCopyMode = False
定義一個Shape對象並播放:
'Opens a new PowerPoint presentation based on template and pastes data into Slide 2 of Powerpoint from Excel
Dim PPapp As PowerPoint.Application, PPpres As PowerPoint.Presentation, PPslide As PowerPoint.Slide, PPShape As Object
Dim XLws As Worksheet
Set XLws = ActiveSheet
Set PPapp = New PowerPoint.Application
Set PPpres = PPapp.Presentations.Open("C:\Users\Colin\Dropbox (Edge45)\Edge45 Team Folder\Edge45 Company Documents\Templates\Powerpoint Templates\Edge45 Audit Template Macro.potm", Untitled:=msoTrue)
PPapp.Visible = True
Set PPslide = PPpres.Slides(2)
XLws.Range("A1:D16").Copy
Set PPShape = PPslide.Shapes.PasteSpecial(DataType:=ppPasteHTML, Link:=msoFalse)
Application.CutCopyMode = False
With PPShape
.Top = 10
.Height = 100
.Left = 10
.Width = 100
End With
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.