Header
PowerPoint tips, hints and tutorials that will change your presentations for ever!

INDEX

 

Jigsaws
Sounds
Video
Custom Shows
vba code
NaviSlides
Games for teachers
Bullets
Triggers
Security
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Animation
Hyperlinks
Set spellcheck language


Home buttonTutorial buttonContact buttonProducts button


SlideID in PowerPoint

Usually when referencing slides in PowerPoint vba people use the SlideIndex property. This is easy because it is directly related to the slide number which is visible in the GUI. Note that the SlideIndex does not necessarily equate to the slide number. If you start numbering from eg 2 then the first slide will still have an index of 1.

Typical Code using SlideIndex

Sub calloutadd()
Dim oshp As Shape
With ActivePresentation.Slides(6)
Set oshp = .Shapes.AddCallout(msoCalloutOne, 10, 10, 10, 10)
End With
End Sub

This adds a callout to slide with SlideIndex = 6 at the Left and Top values specified and with height and Width =10 / It works fine UNTIL you reorder or add or delete slides so that the slide is no longer the sixth slide. This is where you need SlideID's

SlideID

Powerpoint assigns a unique SlideID to every new slide. The first slide added will have an ID of 256 and every new slide will have an ID one higher than the current highest value. The SlideID is not affected by moving slides or adding or deleting other slides. If you write code to change a slide based on the ID it will always work (assuming the SlideID exists)

The same code assuming that slide 6 has an ID of 261

Sub calloutadd2()
Dim oshp As Shape
With ActivePresentation.Slides.FindBySlideID(261)
Set oshp = .Shapes.AddCallout(msoCalloutOne, 10, 10, 10, 10)
End With
End Sub

How to Determine the SlideID

This code will mark each slide with its ID. Running just the delete code will remove the markings.

Sub addID()
Dim osld As Slide
Dim oshp As Shape
Dim i As Integer
Call deleteID
For Each osld In ActivePresentation.Slides
Set oshp = osld.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 10, 100, 20)
With oshp
.TextFrame.TextRange = CStr(osld.SlideID)
.Tags.Add "ID", "yes"
End With
Next osld
End Sub
Sub deleteID()
Dim osld As Slide
Dim i As Integer
For Each osld In ActivePresentation.Slides
For i = osld.Shapes.Count To 1 Step -1
If osld.Shapes(i).Tags("ID") = "yes" Then osld.Shapes(i).Delete
Next i
Next osld
End Sub

Don't know how to use vba? Go here.

 
 

Back to the Index Page

POWERPOINT BLOG

Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation