.PPT macro-enabled show path

2019-09-07 02:18发布

问题:

I am trying to save a presentation as a macro-enabled show in PowerPoint, and I'm running into a problem when I do. This code that I'm using works great when I'm save as a macro-enabled presentation - but not as a macro-enabled show:

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"

The problem is that when I save it as a macro-enabled show and try to run it, it stops at the <--- line of code because there "is no active presentation. When you save powerpoint as a macro-enabled show, then no "presentation" (powerpoint window) opens, just the slideshow window.

I need a way of finding the active show path that doesn't reference an activepresentation, which doesn't exist.

Thank you for your time!

Respectfully, Dustin

回答1:

Since you haven't answered my question about where the code is running FROM, I'm going to assume that it's from within PPT and that there are no other applications involved. That being the case, this works fine, either from a PPTM or 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