Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA to insert footer in PowerPoint

1,694 views
Skip to first unread message

Aurora

unread,
May 9, 2009, 6:56:23 PM5/9/09
to
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

Steve Rindsberg

unread,
May 10, 2009, 12:44:49 AM5/10/09
to
In article
<daebb34a-bf4f-4147...@e24g2000vbe.googlegroups.com>,
Aurora wrote:
> 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).

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
' footer shape 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
' no footer; 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 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


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/

Aurora

unread,
May 10, 2009, 1:38:56 PM5/10/09
to
On May 10, 12:44 am, Steve Rindsberg <ab...@localhost.com> wrote:
> In article
> <daebb34a-bf4f-4147-8f73-04589b121...@e24g2000vbe.googlegroups.com>,

>
> Aurora wrote:
> > 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.
>
> > Thanks
>
> ==============================
> 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.

Steve Rindsberg

unread,
May 10, 2009, 4:06:20 PM5/10/09
to

> 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.

Great ... glad to hear it.

srikanth...@gmail.com

unread,
Dec 13, 2018, 1:42:25 AM12/13/18
to
Hi Below code doesn't work for my presentation slide. Can you please do the needful to get footer edited?
I am using version 2010.
0 new messages