使用VBA从Excel打开PowerPoint演示文稿,然后将该演示文稿设置为variables

我必须发布大量的Excel图表到一个特定的PowerPoint文档,我正在Excel VBA中构build一个macros来为我做。

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

 Dim myPresentation As PowerPoint.Presentation Dim PowerPointApp As PowerPoint.Application PowerPointApp.Presentations.Open Filename:="obscured filepath and name"` 

显然有一些额外的代码,但我想设置演示文稿,我只是打开第3行设置为MyPresentationvariables,所以我可以引用我刚刚打开的文档。

我最终find了MVP Andy Pope的解决scheme。

一些相关的代码片段为未来的用户。 (仅供参考当我遇到问题时,我的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)