我正在尝试将演示文稿保存为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"
问题在于,当我将其保存为启用宏的节目并尝试运行时,它会停在&lt; ---代码行,因为“没有活动的演示文稿。当您将powerpoint保存为宏时-enabled show,然后没有“演示”(powerpoint窗口)打开,只是幻灯片窗口。
我需要一种方法来查找不引用不存在的activepresentation的活动show path。
感谢您的时间!
尊敬地,达斯汀
答案 0 :(得分:0)
由于您还没有回答我关于代码运行FROM的问题,我将假设它来自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