Slide numbers without hidden slides

J

JoAnn

I'm having trouble getting the displayed slide numbers in my presentation to
skip hidden slides. Using Office 2003 with an XP system.

I added John Wilson's code found in this site but it still doesn't work. Not
sure what I'm doing wrong.

Here is the code being used:

Sub numbers()
Dim osld As Slide
Dim i As Integer
For Each osld In ActivePresentation.Slides
If osld.SlideShowTransition.Hidden = False Then
i = i + 1
osld.HeadersFooters.Footer.Text = "Slide " & i
Else
osld.HeadersFooters.Footer.Text = "Slide " & i & "H"
End If
Next

With the footer set to show slide numbers, I get the original numbers
including the hidden slides. When I clear that box (since the code seems to
be displaying "slide" plus the number), I get nothing.

We do have something else in the footer (corporate stuff I'm not allowed to
remove) & it's possible that the slide number is hidden below it.

Is there any code that can be added to ensure the slide number appears in
the lower left corner of the footer, on top of anything else?

Also, once this is set will it stick? And adjust when other slides are
hidden or made visible? Do I need some kind of code to ensure it runs
automatically every time the presentation is opened?

Thanks for your help!
 
J

John Wilson

Try this code then. It will not run automatically when you eg add or hide
slides but it will remove "old" numbers and re number the non hidden slides
and can be run whenever you change the presentation

Sub hiddennums()
Dim osld As Slide
Dim i As Integer
Dim otxtbox As Shape
'Remove old numbers
For Each osld In ActivePresentation.Slides
For i = osld.Shapes.Count To 1 Step -1
If osld.Shapes(i).Tags("Number") = "yep" Then _
osld.Shapes(i).Delete
Next i
Next osld
'Number non hidden slides only
For Each osld In ActivePresentation.Slides
If osld.SlideShowTransition.Hidden = False Then
i = i + 1
Set otxtbox = osld.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 500,
20, 20)
With otxtbox
..TextFrame.TextRange = CStr(i)
..Tags.Add "Number", "yep"
End With
End If
Next osld
set otxtbox = Nothing
End Sub

To make this run as you want completely automatically is possible but it
would reaally be best as an add in and you would need to understand events in
vba code
--
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
J

JoAnn

Thanks ... that works!

Is there anyway I can control the font color & size ? What would I need to
add & where?
 
J

John Wilson

Sub hiddennums()
Dim osld As Slide
Dim oshp As Shape
Dim i As Integer
Dim otxtbox As Shape
'Remove old numbers
For Each osld In ActivePresentation.Slides
For i = osld.Shapes.Count To 1 Step -1
If osld.Shapes(i).Tags("Number") = "yep" Then _
osld.Shapes(i).Delete
Next i
Next osld
'Number non hidden slides only
For Each osld In ActivePresentation.Slides
If osld.SlideShowTransition.Hidden = False Then
i = i + 1
Set otxtbox = osld.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 500,
20, 20)
With otxtbox.TextFrame.TextRange
..Text = CStr(i)
'change values to suit
..Font.Color.RGB = RGB(100, 20, 20)
..Font.Size = 10
..Font.Name = "Arial"
End With
otxtbox.Tags.Add "Number", "yep"
End If
Next osld
End Sub
--
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
J

JoAnn

Perfect!!! Thank you very much!
--
JoAnn


John Wilson said:
Sub hiddennums()
Dim osld As Slide
Dim oshp As Shape
Dim i As Integer
Dim otxtbox As Shape
'Remove old numbers
For Each osld In ActivePresentation.Slides
For i = osld.Shapes.Count To 1 Step -1
If osld.Shapes(i).Tags("Number") = "yep" Then _
osld.Shapes(i).Delete
Next i
Next osld
'Number non hidden slides only
For Each osld In ActivePresentation.Slides
If osld.SlideShowTransition.Hidden = False Then
i = i + 1
Set otxtbox = osld.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 500,
20, 20)
With otxtbox.TextFrame.TextRange
.Text = CStr(i)
'change values to suit
.Font.Color.RGB = RGB(100, 20, 20)
.Font.Size = 10
.Font.Name = "Arial"
End With
otxtbox.Tags.Add "Number", "yep"
End If
Next osld
End Sub
--
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 

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

Similar Threads


Top