PDA

View Full Version : VBA to insert slide numbers x of y after 1st slide



jason_kelly
05-02-2011, 11:11 AM
Hi There,

I need your help.

I have the following code below, such that when executed, it inserts the slide numbers on all of the slides. 2 problems however,

1. It always says 1 of 4 on each of the slides and does not change (ie. 2 of 4, 3 of 4, 4 of 4)

2. Instead of putting it on all slides, I would like it to start from the 2nd slide on.

Any help with this is greatly appreciated.



Sub slidnum()
Dim oshp As Shape
With ActivePresentation.SlideMaster.Shapes
Set oshp = .AddTextbox(msoTextOrientationHorizontal, 620, 495, 100, 50)
oshp.TextFrame.TextRange.Font.Name = "Arial"
oshp.TextFrame.TextRange.Font.Size = 12
oshp.TextFrame.TextRange.Text = ActiveWindow.View.Slide.SlideNumber & " of " & ActivePresentation.Slides.Count

End With
ActivePresentation.SlideMaster.HeadersFooters.SlideNumber.Visible = True
Set oshp = Nothing
End Sub


Thanks in advance,

Cheers,

Jay

John Wilson
05-08-2011, 06:55 AM
This should get you closer.

Sub slidnum()
Dim oshp As Shape
With ActivePresentation.SlideMaster.Shapes
Set oshp = .AddTextbox(msoTextOrientationHorizontal, 620, 495, 100, 50)
oshp.TextFrame.TextRange.Font.Name = "Arial"
oshp.TextFrame.TextRange.Font.Size = 12
oshp.TextFrame.TextRange.InsertSlideNumber
oshp.TextFrame.TextRange.InsertAfter " of " & ActivePresentation.Slides.Count
End With
ActivePresentation.PageSetup.FirstSlideNumber = 0
ActivePresentation.Slides(1).DisplayMasterShapes = msoFalse
Set oshp = Nothing
End Sub