通过 VBA 脚本编辑 Powerpoint 图表数据

发布于 2024-10-09 13:40:01 字数 140 浏览 0 评论 0原文

我有一个 PowerPoint 演示文稿,其中包含一个图表,其中包含 Excel 表格中的数据。

我想通过 powerpoint VBA 编辑器编辑此数据..

我该怎么做?我找不到访问 Excel 表数据的方法。

问候

i've a powerpoint presentation with a chart which contains data from an excel table.

I would like to edit this data via the powerpoint VBA editor..

how can i do this? i cant find a way to access the data of the excel table.

greets

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离线来电— 2024-10-16 13:40:01

此代码允许您访问嵌入到 PowerPoint 演示文稿中的 Excel 工作表。

Sub a()

Dim oSl As PowerPoint.Slide
Dim oSh As PowerPoint.Shape

Set oSl = ActivePresentation.Slides(1)

Set oSh = oSl.Shapes(1)

With oSh.OLEFormat.Object.Sheets(1)
    .Range("A1").Value = .Range("A1").Value + 1
    .Range("A2").Value = .Range("A2").Value - 1
End With

Set oSl = Nothing
Set oSh = Nothing

End Sub  

如果图表链接到您修改的数据,它可能会自动更新。如果不是,强制重新计算。

哈!

编辑

通过以下更改,它可以在 Office 2007 中运行:

With oSh.OLEFormat.Object.WorkSheets(1)
    .Range("A1").Value = .Range("A1").Value + 1
    .Range("A2").Value = .Range("A2").Value - 1
End With

This code allows you to access an Excel WorkSheet embedded into a PowerPoint presentation.

Sub a()

Dim oSl As PowerPoint.Slide
Dim oSh As PowerPoint.Shape

Set oSl = ActivePresentation.Slides(1)

Set oSh = oSl.Shapes(1)

With oSh.OLEFormat.Object.Sheets(1)
    .Range("A1").Value = .Range("A1").Value + 1
    .Range("A2").Value = .Range("A2").Value - 1
End With

Set oSl = Nothing
Set oSh = Nothing

End Sub  

If the graph is linked to the data you modify, probably it'll update automagically. If not, force a re-calc.

HTH!

Edit

With the following change it works in Office 2007:

With oSh.OLEFormat.Object.WorkSheets(1)
    .Range("A1").Value = .Range("A1").Value + 1
    .Range("A2").Value = .Range("A2").Value - 1
End With
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文