GoToSlide with name of the slide

O

onintze

Hi!
I want to run the "go to slide" order but using the name
of the slide instead of the index or slide number.
The thing is that I have a big amount of slides and the
number of these slides varies depending on the data
introduced by the user, so I need to find the exact slide,
with its name, to make some changes there, whatever its
slide number or index is.

Until now I have used this, with the index number:

ActiveWindow.View.gotoslide Index:=21

How can I do this using the slide name?

Thanks!
 
S

Shyam Pillai

Pass the name of the slide and the presentation in which to perform search
to this function and it will return the slideindex for that slide.
' ----------------------------------------------------------------------------
Sub Sample()
Dim lngIndex As Long
lngIndex = GetSlideIndexFromName("Slide1", ActivePresentation)
If lngIndex = 0 Then
MsgBox "Could not find slide with provided name.", vbExclamation
Else
'Perform operation here...
End If
End Sub

Function GetSlideIndexFromName(Name As String, oPres As Presentation) As
Long
Dim oSld As Slide
For Each oSld In oPres.Slides
If oSld.Name = Name Then
GetSlideIndexFromName = oSld.SlideIndex
Exit Function
End If
Next oSld
End Function
' ----------------------------------------------------------------------------
 
D

David M. Marcovitz

Hey Shyam! Is there a reason why it has to be so complicated? Wouldn't
the following work?

ActivePresentation.SlideShowWindow.View.GotoSlide _
(ActivePresentation.Slides(theName).SlideIndex)

where theName is the name of the slide you want to go to. Or is all of
your extra complexity for error checking?

--David

--
David M. Marcovitz, Ph.D.
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top