Consulting

Results 1 to 3 of 3

Thread: Password to next slide or custom show

  1. #1
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    271
    Location

    Password to next slide or custom show


    Hi all, I have received loads of help with vba for excel from this site, hope to get some help for powerpoint

    I have been tasked with providing a solution for the following problem:
    I have a powerpoint show used for training and is broken into different levels using custom shows.
    We want the users to enter a password before they can access the next slide or custom show
    I have the following code linked to a simple user form which has a text box for input and an OK button
    How do I use vba to decide either which slide to go to or which custom show to run?

    Private Sub cmdOK_Click()
    Dim pWord As String
    pWord = txtWord.Value
    If pWord = "test" Then
        'goto slide 2
        ActivePresentation.SlideShowWindow.View.GotoSlide (Slide2) 'does not work
        Unload Me
    Else
        MsgBox "The password is incorrect", vbCritical
        txtWord.Value = ""
        txtWord.SetFocus
    End If
    End Sub
    Thanks in advance
    Last edited by Aussiebear; 04-28-2023 at 02:30 AM. Reason: Adjusted the code tags

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    ActivePresentation.SlideShowWindow.View.GotoSlide(2)
    Should work. If you are using Slide2 as a named slide to avoid using the index which can easily change(?) then I would suggest using the SlideID which is usually fixed.

    eg to go to slide with slideID 257

    Dim i As Long
    i = ActivePresentation.Slides.FindBySlideID(257).SlideIndex
    ActivePresentation.SlideShowWindow.View.GotoSlide i
    you can read a slides ID with
    MsgBox ActiveWindow.Selection.SlideRange(1).SlideID
    Last edited by Aussiebear; 04-28-2023 at 02:32 AM. Reason: Adjusted the code tags
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Tutor
    Joined
    Dec 2006
    Posts
    271
    Location

    Thanks

    Thanks John
    Exactly what I was looking for

Posting Permissions

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