1
我試圖將Excel圖表複製到Powerpoint中的特定佔位符。我曾嘗試使用下面的代碼將Excel圖表複製到Powerpoint中的佔位符
Sub NameShape()
Dim Name$
On Error GoTo AbortNameShape
If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name
Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)
If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If
Exit Sub
AbortNameShape:
MsgBox Err.Description
End Sub
在Excel命名佔位符,據我來,因爲這:
Sub CreateNewReport()
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
Dim pptShape As PowerPoint.Shape
Dim w!, h!, t!, l!
Dim Chart As Chart
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = msoTrue
Set pptPres = pptApp.Presentations.Open("C:\Users\...\Report.pptm")
Set Chart = Worksheets("Analysts").ChartObjects("Chart 2")
Set PPSlide = pptPres.Slides(4)
'PPSlide.Shapes("Analyst.Forecasts").Copy
Set pptShape = pptPres.Slides(4).Shapes(4)
With pptShape
w = .Width
h = .Height
l = .Left
t = .Top
End With
pptShape.Parent.Paste
With Selection
.Width = w
.Height = h
.Left = l
.Top = t
End With
ppt.Shape.Delete
End Sub
有誰知道如何把它從這裏?我不能完全弄清楚如何定義我想要複製的圖表,以及如何在Powerpoint中替換shep來粘貼&。理想情況下,我想用圖表的圖元文件替換它,但圖片也可以。
非常感謝您的幫助!