PDA

View Full Version : Cannot go back to previous slides



Billbill
03-31-2023, 10:39 AM
Hi this is my very first post.

I have been trying to get my code to work for over a month now with no success. I have tried smaller codes and much larger codes and none seem to work.

My Code should remember the last 10 PowerPoint slides that I have visited, so when I use a shape to run the Sub GoBack() the slides will go back each time to previous slide I had visited.

I want this to work automatically so when the slide is visited the Sub AddSlideToList() is activated.


The code Sub AddSlideToList() is not being activated at all. If I use a shape to run the Sub AddSlideToList() when on the slide that slide number is shown in the Immediate Window which is correct. (Added slide ? to list) and I can then use a shape Sub GoBack() which works fine.

The issues is this code will not run on its own as its meant to do. I have no idea what I am doing wrong. I am running this code in Module 1
I only want to be able to us Sub GoBack() Are you able to help please.



Private Sub SlideShowNextSlide(ByVal Wn As SlideShowWindow)
AddSlideToList 'Call the AddSlideToList Sub when the slide changes
End Sub

Sub AddSlideToList()
If SlideList.Count = 10 Then SlideList.Remove 1
SlideList.Add ActivePresentation.SlideShowWindow.View.Slide.SlideNumber
Debug.Print "Added slide " & ActivePresentation.SlideShowWindow.View.Slide.SlideNumber & " to list"
End Sub

Sub GoBack()
If SlideList.Count > 0 Then
Dim SlideNumber As Long
SlideNumber = SlideList(SlideList.Count)
SlideList.Remove SlideList.Count
ActivePresentation.SlideShowWindow.View.GotoSlide SlideNumber
End If
End Sub



My Immediate window will look like this if i run the Sub AddSlideToList() manually

-1
Added slide 3 to list
Added slide 3 to list
Added slide 4 to list
Added slide 5 to list
Added slide 8 to list
Added slide 8 to list
Added slide 8 to list
Added slide 8 to list
Added slide 8 to list
Added slide 8 to list
Added slide 8 to list
Added slide 10 to list
Added slide 11 to list
Added slide 7 to list
Added slide 1 to list
Added slide 1 to list
Added slide 1 to list
Added slide 2 to list
Added slide 3 to list
Added slide 6 to list
Added slide 10 to list
Added slide 11 to list
Added slide 4 to list
Added slide 3 to list
Added slide 4 to list
Added slide 5 to list
Added slide 7 to list
Added slide 10 to list

Billbill
04-01-2023, 09:24 AM
I don’t think it’s the Code I must be doing something wrong

John Wilson
04-03-2023, 04:02 AM
SlideShowNext will only run autmatically if you have it in a class module and declare it WithEvents and instigate it usually in a ppam AddIn.

If this makes no sense to you then you are biting off more than you can chew because it is not simple.

One answer is to use this instead

Sub OnSlideShowPageChange (SW as SlideShowWindow)

'do whatever
End Sub


This will work but can be unreliable after saving. You can help reliability by adding any activX item from the developer toolbox to slide 1 (no code needed). You can hide it using the Selection Pane.

Paul_Hossler
04-03-2023, 09:58 AM
I'd just insert an Action Button. Not perfect 100%, but works reliably

30706

Billbill
04-03-2023, 10:52 AM
Hi Thanks a million for your replies.

John you are correct this is most likey beond me at my stage :banghead: but you did manage to answer my question I was hoping that theSub OnSlideShowPageChange (SW as SlideShowWindow) would just run but not to be. I have made a work around for this to happen using code which does now work okay. I wont post the code unless anybody asks to see it.

Hi Paul the hyperlink button is a great idea but the issue I had was that the slides would be random ie slide, 1, 3, 320, 620, 5 etc which made this a bit more difficult. Its a simulator that I am building so lots of radom pages jumping around .

Best regards

Adrian