2017-01-15 132 views
1

我有一個從指定位置打開PowerPoint文件的Excel宏。 PowerPoint文件是一個模板,但我需要宏來創建基於模板設計的新演示文稿,而不是打開模板本身。 我的代碼將打開模板,而不是基於該模板的一個新的演示文稿,併爲:在Excel中使用VBA使用PowerPoint模板創建新的PowerPoint演示文稿

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 

有誰知道我怎麼能修改此讓它創建基於模板的新演示文稿,而不是打開模板本身?

非常感謝提前。

科林

回答

1

在我看來,你應該打開設置爲true與Untitled參數(Open方法)的模板文件。

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

Presentations.Open Method (PowerPoint)

打開該文件沒有標題。這相當於創建文件的副本 。

+0

太棒了,非常感謝你! – Superhans

相關問題