首页 > 解决方案 > 如何在 Excel VBA 中打开“带有新的 PPT 文件”选项

问题描述

我有以下代码来打开 ppt 文件,但我需要使用新选项打开该文件(参考图片)。这样现有的文件就不会在不知不觉中受到干扰。请提供任何帮助。

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

标签: excelvbapowerpoint

解决方案


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 

推荐阅读