简体   繁体   中英

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. The PowerPoint file is a template.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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