问题
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