【问题标题】:copy Excel chart to placeholder in Powerpoint将 Excel 图表复制到 Powerpoint 中的占位符
【发布时间】:2012-03-03 04:03:18
【问题描述】:

我正在尝试将 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。理想情况下我想用图表的元文件替换它,但图片也可以。

非常感谢您的帮助!

【问题讨论】:

    标签: excel vba powerpoint


    【解决方案1】:

    我使用此代码从 Excel 制作 ppt 并粘贴到 placeHolder;

    Nr = 2
    
    'Verifique os graficos nos arquivos
        For Each Grf In E.ActiveSheet.ChartObjects
            Grf.Copy
            Sld.Shapes.Placeholders(Nr).Select msoCTrue
            P.ActivePresentation.Windows(1).View.PasteSpecial (ppPasteMetafilePicture)
           Nr = Nr + 1
        Next Grf
    
    End If
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-10
      • 2017-03-13
      • 2013-10-11
      • 2020-05-18
      • 2015-10-14
      • 2020-12-21
      相关资源
      最近更新 更多