Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Add presentation file name to each slide master

Problem

It's sometimes convenient to have the name of the current file included in a footer or as some other part of the file. The feature's built into Word and Excel. We've begged MS for it in PowerPoint too, to no avail.

So taking matters in hand ourselves, we'll let VBA do the job.

Solution

First run AddNamedShape with the slide presentation file or template file open. This adds a text box to each slide master in the presentation, then gives the text box a name so we can easily locate it later.

Then when you're ready to add the full filename of the presentation (or another presentation built off a template that's had this macro run on it), run AddPath. If you save the presentation under a new name or move it to a new location, run AddPath again to update the text.

Sub AddNamedShape()
' Run this once on each template or presentation to create a
' text shape on masters that we can find later with the next macro

Dim x As Long
Dim oSh As Shape

With ActivePresentation

    ' On each slidemaster in the presentation:
    For x = 1 To .Designs.Count
        ' Create a textbox at 10 points from left, 
        ' 100 points from bottom of slide
        ' Make it 25 points high, 300 points wide
        ' Change any of these numbers at will
        Set oSh = _
           .Designs(1).SlideMaster.Shapes.AddTextbox(msoTextOrientationHorizontal, _
            10, _
            .PageSetup.SlideHeight - 100, _
            300, _
            25)

        ' Give it a name so we can find it later
        oSh.Name = "FullPath"

        ' Add some formatting and dummy text
        With oSh.TextFrame.TextRange
            .Font.Name = "Arial"
            .Font.Size = 12
            .Text = "Full name of file will appear here"
        End With

    Next
End With

End Sub

Sub AddPath()
' Run this to add the full name of the presentation to the
' slide masters

Dim x As Long

With ActivePresentation
    On Error Resume Next ' in case the shape isn't there

    For x = 1 To .Designs.Count
        .Designs(x).SlideMaster.Shapes("FullPath").TextFrame.TextRange.Text _
         = .FullName
    Next

End With

End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Add presentation file name to each slide master
http://www.pptfaq.com/FAQ01180-Add-presentation-file-name-to-each-slide-master.htm
Last update 05 November, 2013
Created: 05 November, 2013