Insert total number of slides in PowerPoint 2007

If you're looking for an option or configuration setting that will just automatically add it to every presentation you create, there isn't one. However, if you edit the Header or Footer, you can automatically add slide numbers there and have them appear on all slides.

http://office.microsoft.com/en-us/powerpoint/HA101181931033.aspx


This is basically pwrpntuser's code extended to full executable guide.

Creating macro

  1. In PowerPoint 2007 and newer make sure, that you saved your presentation under .pptm extension (standard presentation with macros allowed).

  2. Make sure, that you have added slide numbers using method described in this article1.

  3. Open "Macro" window 2. In PowerPoint 2007 and newer, click on View tab (last) and then on Macro button in last toolbar group. In eariler versions select Tools > Macro from menu.

  4. Type a name for your macro (say PageCountUpdater) and click Create.

  5. Paste macro code (from pwrpntuser's answer or below) between Sub PageCountUpdater() and End Sub. Change van in the most indented line to of or anything similar in your lang.

  6. Save macro and close Microsoft Visual Basic for Applications.Go back to PowerPoint.

You're done. Code to be inserted (full and with corrected "glue-word"):

Sub PageCountUpdater()
    Dim s As Slide
    Dim shp As Shape

    For Each s In ActivePresentation.Slides
        s.DisplayMasterShapes = True
        s.HeadersFooters.SlideNumber.Visible = msoTrue

        For Each shp In s.Shapes
            If Left(shp.Name, 12) = "Slide Number" Then
                shp.TextFrame.TextRange.Text = s.SlideNumber & " of " & ActivePresentation.Slides.Count
            End If

        Next
    Next
End Sub

Executing macro

  1. Open "Macro" window again.

  2. Select saved PageCountUpdater macro and hit Run.

You have to do this each time manually. A keyboard shortcut would be most welcome. But... there is no way to change PowerPoint's shortcuts, except for buying a commercial plugin, for which you have to pay price starting at 20 bucks per one computer. See end of this or this article for a details.

Deleting macro

This macro is run only, when you need it. It is not a live-macro. It updates field with actual slide count and that's it. Field itself is a standard text field. No magic. This means, that you can easily convert your file back to .pptx and throw this macro away, once you're sure, that your presentation is done and you'll be adding no more slides to it. Field will remain in their places with their values untouched, once macro is removed.

This is comfortable as many users does not like documents with macros and many presentation places, fairs, conferences etc. simply won't let you run .pptm file.

This is also good, because this macro recreates numbering fields on all slides (except title ones -- see footnote no 1 at the end), even if you remove them manually. Therefore you should run it one last time, after you're sure about final number and order of slides and then you can remove it.

Opening macro-enabled file

If you decide to keep .pptm extension and macro inside, you'll have this document always opened with macros disabled and you'll have to click Enable macros each time (if you run on default settings) to enable them.

If documents are your own, you trust, that they contain no malicious code and they're all stored in a secure location (i.e. not in some temporal or shared folder), you can change each Office program settings to have these files always opened with macros enabled.

The easiest way is to add folder with macro-enabled presentations to secure locations in PowerPoint.

To do this:

  1. Click File tab, Options button, Trust Center section and Trust Center Settings button.

  2. Go to Trusted locations section (second) and click on Add new location... button.

  3. Paste or select folder path into Path field and optionally check, that all subfolders in added location should also be treated as trusted.

  4. Click OK three times to confirm and close all opened windows. Reopen your macro-enabled document.

From this point on, all documents opened from just added location should not display any warning and should always be opened with macros enabled. You'll find much more details on this matter in this Office.com support document.

Footnotes

1In most versions of PowerPoint the meaning title slide is determined not as first slide in presentation, but as any slide styled as title slide. You can see diffreent slide types, when inserting new one. This mean that, if you have no slide styled as title, you'll have page numbers added to all slides. And opposite -- if you used many title slides inside presentation, for example to mark different sections or blocks, you'll have numbering missing on all of them.

2All GUI elements' names are on-the-fly translation from my Polish edition of PowerPoint 2010. In other releases or language editions of PowerPoint they may be slightly different. Adjust accordingly.


First make sure every slide has a normal slidenumber. Then add a module, insert the following piece of code and press F5 (Start).

Dim s As Slide
Dim shp As Shape

For Each s In ActivePresentation.Slides
    s.DisplayMasterShapes = True
    s.HeadersFooters.SlideNumber.Visible = msoTrue

    For Each shp In s.Shapes
        If Left(shp.Name, 12) = "Slide Number" Then
            shp.TextFrame.TextRange.Text = s.SlideNumber & " van " & ActivePresentation.Slides.Count
        End If

    Next
Next

Bill Dilworth's add-in for PowerPoint may help you, depending on which version of PowerPoint you're using. This is exactly its purpose.