gpt4 book ai didi

excel - 使用 VBA 从 Excel 中打开 PowerPoint 演示文稿,然后将该演示文稿设置为变量

转载 作者:行者123 更新时间:2023-12-01 07:14:40 24 4
gpt4 key购买 nike

我必须将大量 Excel 图表发布到特定的 PowerPoint 文档中,并且我正在 Excel VBA 中构建一个宏来为我做这件事。

我能够正确打开要更新的 PowerPoint 演示文稿,但是我不知道如何将刚刚打开的演示文稿设置为名为 MyPresentation 的变量.

Dim myPresentation As PowerPoint.Presentation
Dim PowerPointApp As PowerPoint.Application

PowerPointApp.Presentations.Open Filename:="obscured filepath and name"`

显然还有一些额外的代码,但我试图将我刚刚在第 3 行打开的演示文稿设置为 MyPresentation变量,以便我可以引用刚刚打开的文档。

最佳答案

我最终找到了 MVP Andy Pope 的解决方案。

future 用户的一些相关代码片段。 (仅供引用,当我遇到问题时,我的 PPT 已经可见)

Dim DestinationPPT As String
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation

'Easier to define manually set links up front so it's easier to change/modify
DestinationPPT = "C:\yourfilepath\yourfilename.pptx"`

查找电子表格大师从 Excel VBA 打开 PPT 的指南

然后:
Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)

关于excel - 使用 VBA 从 Excel 中打开 PowerPoint 演示文稿,然后将该演示文稿设置为变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31594476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com