> I have now checked slide access using the suggested code and that works fine
> using the numerical position of the slide as the value in the code e.g. 5 for
> the fifth slide. However I wanted to goto my named slide e.g. "MyNamedslide"
You can do that as well. This function returns the slide index of any named
slide (or 0 if there's no slide by that name):
Function IndexOfSlideNamed(sSlideName As String) As Long
' Returns the slide index of the named slide or 0 if slide not present
Dim oSl As Slide
Dim lTemp As Long
For Each oSl In ActivePresentation.Slides
If UCase(oSl.Name) = UCase(sSlideName) Then
lTemp = oSl.SlideIndex
End If
Next
IndexOfSlideNamed = lTemp
End Function
To test it:
Sub TestMe()
MsgBox IndexOfSlideNamed("Bubba")
End Sub
To use it, you'd do something like:
Dim lTemp as Long
lTemp = IndexOfSlideNamed("Bubba")
If lTemp > 0 Then ' you know the slide exists
ActivePresentation.SlideShowWindow.View.GotoSlide lTemp
Else
' do whatever you need to do if the slide's not there
End If
> > > ActivePresentation.SlideShowWindow.View.GotoSlide 5
> > >
[quoted text clipped - 33 lines]
> > > >
> > > > Bob L
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
David M. Marcovitz - 12 Jul 2007 16:38 GMT
Steve's code is the complete version with all the bells and whistles
(mainly error checking). I usually use something like:
ActivePresentation.SlideShowWindow.View.GotoSlide _
ActivePresentation.Slides("MyNamedSlide").SlideIndex
It's simple, but if you screw up (like trying to go to a named slide that
doesn't exist), it won't do anything.
--David

Signature
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
>> I have now checked slide access using the suggested code and that
>> works fine using the numerical position of the slide as the value in
[quoted text clipped - 82 lines]
> PPTools: www.pptools.com
> ================================================
Steve Rindsberg - 13 Jul 2007 14:44 GMT
> Steve's code is the complete version with all the bells and whistles
> (mainly error checking). I usually use something like:
[quoted text clipped - 4 lines]
> It's simple, but if you screw up (like trying to go to a named slide that
> doesn't exist), it won't do anything.
And as long as you test the presentation beforehand to make sure it all works,
I'd go with yours, especially if there are lots of slides in the show. It'll
be marginally faster, I'd bet.
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
flying_pig - 15 Jul 2007 15:40 GMT
David,
This is even better for my purpose as I keep a list of all slide and object
names and have a macro to read/write/edit them if needed.
> Steve's code is the complete version with all the bells and whistles
> (mainly error checking). I usually use something like:
[quoted text clipped - 93 lines]
> > PPTools: www.pptools.com
> > ================================================
flying_pig - 13 Jul 2007 10:04 GMT
Steve,
Thanks for the Function it works as needed.
> > I have now checked slide access using the suggested code and that works fine
> > using the numerical position of the slide as the value in the code e.g. 5 for
[quoted text clipped - 78 lines]
> PPTools: www.pptools.com
> ================================================