【问题标题】:How to modify Powerpoint Chart ChartData by Excel VBA如何通过 Excel VBA 修改 Powerpoint Chart ChartData
【发布时间】:2019-04-03 08:13:41
【问题描述】:

我正在尝试使用 Excel-VBA 在 Powerpoint 中修改 ChartData(值)。 ChartData 未链接到其他 Excel 工作簿。

检查: - PowerPoint 已打开 - 所需的演示文稿已打开 - 图表在幻灯片 4 上

行为: - 图表标题更改 - 带有 ChartData 的工作簿打开 - 运行时错误“424”:需要对象 - 调试标记以下行:

Chart.ChartData.Workbook.Worksheets("Tabelle1").Range("B2:B5").Value = 50

希望有人可以帮助我... :-)

Sub ModifyChartData()

Dim pptApp As Object
Dim pptPres As Presentation

Set pptApp = GetObject(, "PowerPoint.Application")
Set pptPres = pptApp.ActivePresentation


pptPres.Slides(4).Shapes("Diagramm1").Chart.ChartTitle.Text = "Sales Overview"
pptPres.Slides(4).Shapes("Diagramm1").Chart.ChartData.Activate
Chart.ChartData.Workbook.Worksheets("Tabelle1").Range("B2:B5").Value = 50
Workbooks.Close

End Sub

【问题讨论】:

    标签: excel vba charts powerpoint


    【解决方案1】:

    例子:

    代码:

    Set pptApp = GetObject(, "PowerPoint.Application")
    Set pptPres = pptApp.ActivePresentation
    pptPres.Slides(1).Shapes(1).Chart.ChartTitle.Text = "Sales Overview"
    pptPres.Slides(1).Shapes(1).Chart.ChartData.Activate
    pptPres.Slides(1).Shapes(1).Chart.ChartData.Workbook.Worksheets("Blad1").Range("B2:B5").Value = 50
    

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-18
      • 1970-01-01
      • 2018-02-23
      相关资源
      最近更新 更多