none
Powerpoint 2010 VBA RRS feed

  • Question

  • I use VBA to change the footer for a presentation in PowerPoint 2010 and that works. But when I add a new slide in active presentation, I get the old unchanged footer on this new slide. I want the changed footer!
    How to get the changed footer on new slides automatically?
    I use TitleMaster.HeadersFooters and DateAndTime.Text in my vba code.

    I have tried to solve it, but I can´t - I really need help from you.

    Thank You!

    • Moved by Cindy Meister MVPModerator Wednesday, January 4, 2012 7:14 AM not using VSTO technology (From:Visual Studio Tools for Office)
    Tuesday, January 3, 2012 4:01 PM

Answers

  • I have solved it!
    I added this to my code:

               oSlide.CustomLayout.HeadersFooters.DateAndTime.Text = txtMiddle
               (txtMiddle keeps my text)

    Kind regards
    RedAmaryllis

     

     

    Friday, January 6, 2012 7:33 AM

All replies

  • You need to apply the layout of the previous slide that has the footer as you have modified it.  Here is a code example that shows how to apply a custom layout from a previous slide and a fixed standard layout.

    Sub addingSlides()
        Dim ppt As Presentation
        Set ppt = ActivePresentation
        Dim slide As slide
        Dim pptLayout As CustomLayout
        Set pptLayout = ppt.Slides(1).CustomLayout
        
        'the following adds a slide "2" and applies the same layout as slide 1
        ppt.Slides.AddSlide 2, pptLayout
        'as an alternative you can apply a preset layout as shown below
        ppt.Slides(2).Layout = PowerPoint.ppLayoutComparison
        
    End Sub
    
    

     


    Kind Regards, Rich ... http://greatcirclelearning.com
    Wednesday, January 4, 2012 5:07 AM
  • Thank you for answer, but my question was the following:

    I can change the footer for all slides in a presentation by VBA code - that works fine.
    But when I afterwards add a new empty slide manually by the New slide icon in the ribbon - I get the wrong footer, not the changed one, on the new slide. Note that I had changed the footer both for the individual slides and for all the slideMasters.

    As you can´t record macros in PPT 2010 it´s difficult to get the exact VBA code for Insert / Header-Footer for all presentations.
    Have you any code - please paste it here!

    I want an idea how to solve my problem above.
    If you have someting, please send an answer.

    Thank you!

    Wednesday, January 4, 2012 11:17 AM
  • I have solved it!
    I added this to my code:

               oSlide.CustomLayout.HeadersFooters.DateAndTime.Text = txtMiddle
               (txtMiddle keeps my text)

    Kind regards
    RedAmaryllis

     

     

    Friday, January 6, 2012 7:33 AM
  • Hi RedAmaryllis,

     

    Thanks for sharing your solution in the MSDN Forum. It’s very beneficial for other community members who have similar issue to see how you solved your issue.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 9, 2012 8:44 AM
    Moderator