PDA

View Full Version : [SOLVED] Password to next slide or custom show



lifeson
10-16-2007, 07:29 AM
:help
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 : pray2:

John Wilson
10-16-2007, 08:13 AM
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

lifeson
10-16-2007, 10:33 PM
Thanks John :clap: :bow:
Exactly what I was looking for