Create new powerpoint presentation from powerpoint template using VBA in Excel

白昼怎懂夜的黑 提交于 2020-02-02 09:47:53

问题


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:

   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


回答1:


In my opinion, you should open your template file with the Untitled parameter (Open method) set to true.

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

According to Presentations.Open Method (PowerPoint),

Opens the file without a title. This is equivalent to creating a copy of the file.



来源:https://stackoverflow.com/questions/41666881/create-new-powerpoint-presentation-from-powerpoint-template-using-vba-in-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!