Search code examples
excelvbapowerpoint

How to open "PPT file with new" option in Excel VBA


I have below code to open the ppt file, but I need to open that file with new option (Refer image). So that existing file will not be disturbed unknowingly. Any help please.

Sub openfile()
Dim objPP As Object
Dim objPPFile As Object
Set objPP = CreateObject("PowerPoint.Application")
objPP.Visible = True
Set objPPFile = objPP.Presentations.Open("E:\Test\Tempplate.pptx")
End Sub

Solution

  • Sub openfile()
    Dim objPP As Object
    Dim objPPFile As Object
    Set objPP = CreateObject("PowerPoint.Application")
    objPP.Visible = True
    ts = Format(Now(), "MMDDYYYY_HHMM")
    fn = "E:\Test\New_" & Trim(ts) & ".pptx"
    FileCopy "E:\Test\Tempplate.pptx", fn
    Set objPPFile = objPP.Presentations.Open(fn)
    End Sub