我想一个演示文稿保存为PowerPoint启用了宏的表演,我遇到一个问题,当我这样做。 此代码,我使用的作品伟大的,当我另存为启用宏的表现-但不是作为一个启用宏的表演 :
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,不存在主动秀路的方式。
感谢您的时间!
尊敬,达斯汀
既然你还没有回答我对代码运行从那里的问题,我会假设它从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