title: Automatic slide numbering in PowerPoint using VBA
body: <p>I have added a label in PowerPoint 2013 with the following code to show "x of y" at the bottom of all slides, where x is current slide number and y is total number of slides:      </p>
  
  <pre><code>Private Sub Label1_Click()
  Dim p1 As String
  p1 = " of "
  Dim p2 As Integer
  Dim slideNumber As String
  slideNumber = ActiveWindow.Selection.SlideRange.slideNumber
  p2 = ActivePresentation.Slides.Count
  Label1.Caption = slideNumber &amp; p1 &amp; p2
  
  End Sub
  </code></pre>
  
  <p>The code works perfectly for the slide on which I have added the label e.g. it shows "9 of 29" for slide 9 of my total 29 slides, however when I copy and paste the label on other slides, it still shows "9 of 29" which is wrong as I expect it to automatically reflect the current slide number.   </p>