使用Excel中的VBA从PowerPoint模板创建新的PowerPoint演示文稿

4

我有一个Excel宏,可以从指定位置打开一个PowerPoint文件。这个PowerPoint文件是一个模板。

我需要基于这个模板设计创建一个新的演示文稿。

我的代码会打开模板,而不是基于该模板创建一个新的演示文稿:

Sub Open_PowerPoint_Presentation()
    'Opens a PowerPoint Document from Excel
    
    Dim objPPT As Object
    
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    
    'Change the directory path and file name to the location
    'of your document
    
    objPPT.Presentations.Open "C:\Users\Colin\Documents\Custom Office Templates\PowerPoint Templates\Edge45 Monthly Report Template Macro.potm"
    
End Sub
1个回答

6

我认为,你应该使用 Open 方法并将参数 Untitled 设置为 true 来打开模板文件。

objPPT.Presentations.Open FileName:="MyTemplate Macro.potm", Untitled:=msoTrue

根据Presentations.Open方法(PowerPoint), 打开文件但没有标题。这等同于创建文件的副本。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接