VBA to insert footer in PowerPoint

A

Aurora

Can somebody please help me with the following. I need a macro to
insert a document property into the footer of all presentations before
they are saved (regardless of how they were originally formatted).

The following works fine, assuming the slides already have a footer
defined through the master:

For Each s In ActivePresentation.Slides
s.DisplayMasterShapes = True
s.HeadersFooters.Footer.Visible = msoTrue
s.HeadersFooters.Footer.Text = [value I want to insert]
Next

However, if there is no footer area in the presentation, I get an
error:
HeaderFooter (unknown member): Invalid request

So my question is, is there are way to create a footer area in the
presentation via VBA? This needs to handle ppt 2007 and older file
versions.

Thanks
 
A

Aurora

Can somebody please help me with the following.  I need a macro to
insert a document property into thefooterof all presentations before
they are saved (regardless of how they were originally formatted).

This should get you there for 2007; a bit of adjustment might be needed
for 2003 and prior:

Dim s As Slide
Dim oSh As Shape

For Each s In ActivePresentation.Slides

    ' we're going to try to get a reference to the
    'footershape and trap the error that occurs
    ' if it's not present:
    On Error Resume Next
    Set oSh = s.HeadersFooters.Footer
    If Err.Number <> 0 Then
        ' nofooter; add one to the master:
        ' adjust coordinates as needed
        Call s.Master.Shapes.AddPlaceholder(ppPlaceholderFooter, _
            0, 0, 500, 50)
    End If
    On Error GoTo 0

    ' now it should be safe to add etxt
    s.HeadersFooters.Footer.Visible = msoTrue
    s.HeadersFooters.Footer.Text = "woob woob"

 Next




The following works fine, assuming the slides already have afooter
defined through the master:
For Each s In ActivePresentation.Slides
    s.DisplayMasterShapes = True
    s.HeadersFooters.Footer.Visible = msoTrue
    s.HeadersFooters.Footer.Text = [value I want to insert]
 Next
However, if there is nofooterarea in the presentation, I get an
error:
HeaderFooter (unknown member): Invalid request
So my question is, is there are way to create afooterarea in the
presentation via VBA?  This needs to handle ppt 2007 and older file
versions.

==============================
PPT Frequently Asked Questionshttp://www.pptfaq.com/

PPTools add-ins for PowerPointhttp://www.pptools.com/

Thanks, this worked great! Only had to change the top and left
coordinates to 400, 550 so as to get bottom center position for the
footer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top