2015-06-24 34 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应用程序,因为它是隐含的。说实话,我不能说为什么它以前没有工作。奇怪,不是吗? –