在 Excel 中使用 VBA 从 powerpoint 模板创建新的 powerpoint 演示文稿
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41666881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create new powerpoint presentation from powerpoint template using VBA in Excel
提问by Superhans
I have an excel macro that opens a powerpoint file from a specified location. The powerpoint file is a template but i need the macro to create a new presentation based on the template design rather than open the template itself. My code will open the template rather than a new presentation based on that template and is as follows:
我有一个 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
Does anyone know how I can modify this to make it create the new presentation based on template rather than open the template itself?
有谁知道我如何修改它以使其基于模板创建新的演示文稿而不是打开模板本身?
Many thanks in advance.
提前谢谢了。
Colin
科林
采纳答案by Jeandey Boris
In my opinion, you should open your template file with the Untitled
parameter (Open
method) set to true.
在我看来,您应该将Untitled
参数 ( Open
method) 设置为 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.
打开没有标题的文件。这相当于创建文件的副本。