PDA

View Full Version : How to get VBA Code to Apply to Only One PPT? (not all open PPTs)



Kellaroo
10-10-2022, 10:45 PM
I use this code below to prevent a PPT from scrolling to certain slides. However, it disrupts all other open PPTs. How to make it PPT specific?


Sub OnSlideShowPageChange()
Dim oPres As Presentation
Set oPres = ActivePresentation
With oPres.SlideShowSettings
.LoopUntilStopped = msoCTrue
.AdvanceMode = ppSlideShowUseSlideTimings
.ShowType = ppShowTypeWindow
.Run
End With

Select Case oPres.SlideShowWindow.View.CurrentShowPosition
'might be more flexible
Case 1, 3, 4, 6, 8, 17
With SlideShowWindows(1).View
.GotoSlide (.LastSlideViewed.slideIndex), msoFalse
End With
Case Else
Exit Sub
End Select
End Sub

Kellaroo
10-11-2022, 11:15 PM
I figured out a fix (not sure it's the best fix) but...
I changed the 14th line from
"With SlideShowWindows(1).View"
to
"With oPres.SlideShowWindow.View"

I'm not exactly sure why this original part at the top doesn't suffice in making it PPT specific:
"Set oPres = Presentations("X.pptm")
With oPres.SlideShowSettings"

but it's working now : )