Consulting

Results 1 to 2 of 2

Thread: VBA to insert slide numbers x of y after 1st slide

  1. #1

    VBA to insert slide numbers x of y after 1st slide

    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

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    This should get you closer.

    [VBA]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[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •