Reputation: 1
When trying to execute the following:
Dim lCurrentSlide As Long
' Get the SlideID of the slide currently in view
lCurrentSlide = SlideShowWindows(1).View.Slide.SlideNumber
I get this:
Yesterday the code worked fine. Today - not so much.
Microsoft Visual Basic for Applications 7.1.1128
I copied some code from the internet to print one slide.
It worked fine yesterday.
I renamed all but the first slide in the deck.
It hasn't worked since.
The error message reads:
Run-time error '-2147188160 (800248240)': SlideShowWindows (unknown member) : Integer out of range. 1 is not in the valid range of 1 to 0.
Upvotes: -1
Views: 2671
Reputation: 1
I modified the code:
lCurrentSlide = SlideShowWindows(1).View.Slide.SlideNumber
to read:
On Error Resume Next
Set currentSlide = Application.ActiveWindow.View.Slide
Set currentSlide = ActivePresentation.SlideShowWindow.View.Slide
lCurrentSlide = currentSlide.slideIndex
on Error GoTo 0
And now the procedure executes as expected whether I'm in design mode or slideshow mode.
I studied all the articles posted in the comments as well as some insights from pages found from searches on variations of my original question.
Hopefully soon I will understand more about how to work with slides in vba. I'm pretty good with Excel vba - and I know vba is vba but it's not, really.
Upvotes: 0