optional, PowerPoint Slide Index
some of PowerPoint Slide Index Ms Access Gurus

If you are helped, please return the favor and help support this site, thank you.

VBA to make PowerPoint Slide Index with Master Layout name

Are you planning a presentation that uses PowerPoint? It’s easy for VBA to make an index of your slides so you can ensure good flow — and quick to replace the index when you change things.

Maybe you want to print the index for quick reference so you can quickly jump to any particular slide whilst presenting? (# ENTER during presentation). Or to give your viewers a handy list on a slide where each topic is covered?

Before your PowerPoint presentation, run VBA to create an index with slide number, title, and the slide master layout name,optional (change boolean bMaster at top of procedure to specify). If you want to go to any slide during your presentation, you can just type its number (if you know it!) and press ENTER

The (empty) index slide was created before code was run, and then modified to show the results using copy/paste.

PowerPoint Slide Index

Quick Jump

Goto the very Top  


Download

Download zipped BAS file that you can import into a VBA module for PowerPoint: mod_ppt_SlideIndex_s4p__BAS.zip

If you have trouble with the download, you may need to unblock the ZIP file, aka remove Mark of the Web, before extracting the BAS file. Here are steps to do that: https://msaccessgurus.com/MOTW_Unblock.htm

Goto Top  

VBA

This code lists PowerPoint slide numbers and titles in the Debug window so you can copy and paste the results wherever you want. Optionally you can also show the slide master layout name. Change customize: statement to make bMaster = True or False (default=True).

This VBA runs in PowerPoint for the ActivePresentation, but you could do it from somewhere else (such as Access) if you wanted – or change the code from only reading and reporting to also write information.

Option Explicit 

'*************** Code Start *****************************************************
' module name: mod_ppt_SlideIndex_s4p
'-------------------------------------------------------------------------------
' Purpose  : VBA to list slide number, slide title, 
'              and master layout name (optional)
'            in Debug window
' Author   : crystal (strive4peace)
' Code List: www.msaccessgurus.com/code.htm
' This code: https://msaccessgurus.com/VBA/PowerPoint_SlideIndex.htm
' 231113 s4p
' LICENSE  :
'   You may freely use and share this code, but not sell it.
'   Keep attribution. Mark changes. Use at your own risk.
'------------------------------------------------------------------------------
'           MakeSlideIndex_s4p
'------------------------------------------------------------------------------
Public Sub MakeSlideIndex_s4p() 
's4p ...231113
'populate arrays of slide titles and master layouts
'slide titles modified from code posted by Paul_Hossler here:
' http://www.vbaexpress.com/forum/archive/index.php/t-51599.html
'prints to Immediate window
'   press Ctrl-G to turn on before running
'   to see more, drag by titlebar to float, move, resize

   'example:
   '   -#-   -- Title --           -- Master Layout --
   '    1    VBA Class Basics      Title Slide
   '    2    Why use classes?      Title and Content
   ' ...
   '    5    Demo                  Section Header
   '    6    Switch to Access      Title Only
   ' ...
 
   '              CLICK HERE
   '              Press F5 to Run!

   Dim bMaster  As Boolean 
   bMaster = True       '--------------- customize: show bMaster Layout?
      
   Dim vTitle() As String 
   Dim vMasterName() As String 
   
   Dim nSlide As Long _ 
      ,nNumSlides As Long _ 
      ,iMaxTitle As Integer _ 
      ,iLenTitle As Integer 

   nNumSlides = ActivePresentation.Slides.Count 
   ReDim vTitle(1 To nNumSlides) 
   ReDim vMasterName(1 To nNumSlides) 
      
   iMaxTitle = 0 

   For nSlide = 1 To nNumSlides 
      With ActivePresentation.Slides(nSlide) 
         vMasterName(nSlide) = _ 
            .Master.Design.Parent.CustomLayouts.Item(.CustomLayout.Index).Name 
         
         ' Does the slide have title placeholder?
         If .Shapes.HasTitle Then 
            ' Use the title shape on the slide
            With .Shapes.Title 
               ' get placeholder text - appending ZLS probably not necessary
               vTitle(nSlide) = .TextFrame.TextRange.Text &  ""
            End With 
         Else 
            vTitle(nSlide) =  "(No Title)"
         End If 
         'get maximum Title length for Tab
         iLenTitle = Len(vTitle(nSlide)) 
         If iLenTitle > iMaxTitle Then 
            iMaxTitle = iLenTitle 
         End If 
      End With  'ActivePresentation.Slides(nSlide)
   Next nSlide 
   
   Debug.Print  "-#-"; 
   Debug.Print Tab(7);  "-- Title --"; 
   If bMaster Then 
      Debug.Print Tab(10 + iMaxTitle);  "-- Master Layout --"; 
   End If 
   Debug.Print 
   
   For nSlide = LBound(vTitle) To UBound(vTitle) 
      Debug.Print nSlide; Tab(7); vTitle(nSlide); 
      If bMaster Then 
         Debug.Print Tab(10 + iMaxTitle); 
         Debug.Print vMasterName(nSlide); 
      End If 
      Debug.Print 
   Next nSlide 

End Sub 

'*************** Code End *******************************************************
' Code was generated with colors using the free Color Code add-in for Access.

Goto Top  

VBA Results

When you run the VBA code for your presentation, you will get a list in the Debug Window of your slide numbers and slide titles (Master Layout name optional) such as:

slide numbers and slide titles in the Debug Window

Access Video

If you're interested in watching the Access presentation that was used for the index sample, here it is:

Access Lunchtime: Beginning Access Developer, Part 4 - VBA, by Maria Barnes & crystal (strive4peace) (1:00:27)

Goto Top  

Reference

Shortcut Keys

Here are only a few shortcut keys, on one page, so you can print, highlight, and remember

PowerPoint Presentation Shortcut Keys 1-page PDF

Microsoft Help

Help: ActivePresentation object

Help: Slides collection

Help: SlideRange object

Help: Shapes object and collection

Help: Shapes.Title property

Help: Shape object

Help: Tab function

Goto Top  

Backstory

I was preparing to give a presentation with Maria Barnes for our last in a series for beginning Access developers. The purpose of the presentation was exposure and showing lots of examples for later reference. So, lots of slides! It was great to have VBA make an index that could be copied and pasted to the Index slide to serve as a Table of Contents.

A fellow MVP (Adrian) is preparing for a presentation so the capability to show the master layout name was added.

If you like this page, please let me know, thank you. Donations are much appreciated, thank you.

Share with others

Here's the link for this page in case you want to copy it and share it with someone:

https://msaccessgurus.com/VBA/PowerPoint_SlideIndex.htm

or in old browsers:
http://www.msaccessgurus.com/VBA/PowerPoint_SlideIndex.htm

Get Help with Access and PowerPoint

Let's connect and team-develop your application together. I teach you how to do it yourself. My goal is to empower you.

While we build something great together, I'll pull in code and features from my vast libraries as needed, cutting out lots of development time. I'll give you lots of links to good resources.

Are you preparing for a presentation? Do you have data in Access, Excel, or Word that needs to be presentable and included? Do you want tips to help ensure success for your presentation ? Or any kind of training that I can help you with? I've been using Microsoft Office a long time and leveraging what each of the products can do well makes an application the best it can be. Email me at training@msAccessGurus.com

~ crystal

the simplest way is best, but usually the hardest to see

Goto Top