Consulting

Results 1 to 5 of 5

Thread: Cannot go back to previous slides

  1. #1

    Post Cannot go back to previous slides

    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
    Last edited by Aussiebear; 03-31-2023 at 02:07 PM. Reason: Added code tags to supplied code

  2. #2
    I don’t think it’s the Code I must be doing something wrong

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    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.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    I'd just insert an Action Button. Not perfect 100%, but works reliably

    Capture.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Hi Thanks a million for your replies.

    John you are correct this is most likey beond me at my stage but you did manage to answer my question I was hoping that the
    Sub 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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •