2015-06-24 62 views
0

我試圖將演示文稿另存爲PowerPoint中的啓用宏的演示文稿,而當我這樣做時,我遇到了問題。此代碼,我使用的偉大工程,當我另存爲啓用宏的表現 - 但不是作爲一個啓用宏的表演.PPT啓用宏的顯示路徑

Dim oPPTApp As PowerPoint.Application 
Dim oPPRFile As PowerPoint.Presentation 
Dim oPPTShape As PowerPoint.PlaceholderFormat 
Dim oPPTSlide As PowerPoint.Slide 

Set oPPTApp = CreateObject("PowerPoint.Application") 
oPPTApp.Visible = msoTrue 

'opening an existing presentation 

Dim spath2 As String 
Dim strpath2 As String 
spath2 = ActivePresentation.Path <-- 
strpath2 = spath2 + "\Resources\AIT Diplomas\AIT Diplomas.pptx" 

的問題是,當我把它保存爲一個宏因爲「沒有活動的演示文稿」,當您將Powerpoint保存爲啓用宏的演出時,則不會打開「演示文稿」(PowerPoint)窗口,只是幻燈片放映窗口

我需要一種方法找到沒有引用activepresentation,不存在的活動顯示路徑。

謝謝你的時間!

尊敬,達斯汀

+0

問題/建議:這個代碼應該是從現有的,正在運行的幻燈片演示文稿中或從其他應用程序中運行?使用&代替字符串連接或VB會最終咬你。您是否試圖將啓用宏的演示文稿另存爲具有.PPTX擴展名的文件?那也行不通。 PPTM或PPSM –

+0

史蒂夫,謝謝你的回覆。感謝您對&的提示,而不是+。我沒有試圖在代碼中保存文件,我只是將它作爲演示文稿工作,然後將其保存爲啓用宏的演示文稿,並且我得到上述錯誤(因爲演示路徑進入「C :... Microsoft Office \ Excel「,而不是啓動已保存的啓用宏的演出的位置(我想覆蓋)。 –

+0

在點之前發佈更多代碼可能是一個好主意 –

回答

0

既然你還沒有回答我對代碼運行從那裏的問題,我會假設它從PPT中的,並有不涉及其他應用程序。既然如此,這工作得很好,無論是從一個PPTM或PPSM:

Sub MittedForYourApproval() 

' if the code is running within PPT, you don't need to do it this way: 
' PPT has a reference to itself. 
'Dim oPPTApp As PowerPoint.Application 
'Dim oPPRFile As PowerPoint.Presentation 
'Dim oPPTShape As PowerPoint.PlaceholderFormat 
'Dim oPPTSlide As PowerPoint.Slide 

Dim oPPRFile As Presentation 
' I don't know where you're going with this 
' but PlaceholderFormat <> a shape 
Dim oPPTShape As PlaceholderFormat 
Dim oPPTSlide As Slide 

'Set oPPTApp = CreateObject("PowerPoint.Application") 
'oPPTApp.Visible = msoTrue 

'opening an existing presentation 

Dim spath2 As String 
Dim strpath2 As String 
spath2 = ActivePresentation.Path '<-- 
'strpath2 = spath2 + "\Resources\AIT Diplomas\AIT Diplomas.pptx" 
MsgBox spath2 

End Sub 
+0

Steve,這很好用。理解,oPPRFile,oPPTShape和oPPTSlide只是「喚醒」a介紹?我只是想知道如何解決這個問題:)非常感謝你!附:它表示我沒有足夠的聲望點將其標記爲正確:/ –

+0

oPPRFile,oPPTShape等是分別持有對演示文稿,佔位符格式和幻燈片的引用的對象變量。只要你從PPT本身使用它們,就不需要引用PPT應用程序,因爲它是隱含的。說實話,我不能說爲什麼它以前沒有工作。奇怪,不是嗎? –