.PPT macro-enabled show path

我的未来我决定 提交于 2019-12-12 05:49:09

问题


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


来源:https://stackoverflow.com/questions/31030529/ppt-macro-enabled-show-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!