简体   繁体   English

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

[英]Create new PowerPoint presentation from PowerPoint template using VBA in Excel

I have an Excel macro that opens a PowerPoint file from a specified location.我有一个 Excel 宏,可以从指定位置打开 PowerPoint 文件。 The PowerPoint file is a template. PowerPoint 文件是一个模板。

I need to create a new presentation based on the template design.我需要根据模板设计创建一个新的演示文稿。

My code will open the template rather than a new presentation based on that template:我的代码将打开模板而不是基于该模板的新演示文稿:

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

In my opinion, you should open your template file with the Untitled parameter ( Open method) set to true.在我看来,您应该打开模板文件,并将Untitled参数( Open方法)设置为 true。

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

According to Presentations.Open Method (PowerPoint) ,根据Presentations.Open Method (PowerPoint)

Opens the file without a title.打开没有标题的文件。 This is equivalent to creating a copy of the file.这相当于创建文件的副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM