Microsoft Office Related Pages

Outlook Tips & Tricks

How to delay Outlook Items during Send

VB.NET, VSTO and PowerPoint Footers

The task is quite easy:

In a PowerPoint Presentation (Office 2007) there are a certain number of Designs and Layouts (see here for explanation). And there as well some other slides, which do not conform to any design or layout.

But all of them contain a footer in which a date (the actual year) is contained.

To enhance usability I want to program an Office 2007 Add-In with VSTO 3.0, which updates all the footers of a presentation when a button is clicked.

No big problem I thought. Until I came to the footer. It took me quite some time to find a solution for this problem, since I am a beginner in VB.NET.

Finally I found the post on the MSDN-Blogs about HeaderFooter (unknown member), which was actually the error raised. My final solution then looks something like this:

Private Sub ChangeTemplateYear(ByVal curPres As PowerPoint.Presentation)<br>

       On Error Resume Next

       Dim dsgn As PowerPoint.Design
       Dim lyt As PowerPoint.CustomLayout
       Dim footerState As Boolean
       Dim currentFooter As String

       ’Change in the slidemaster
        With curPres.SlideMaster.HeadersFooters
           With .Footer
                currentFooter = .Text
                .Text = RegularExpressions.Regex.Replace(currentFooter, ”[0-9]{ 4} ”, Date.Now.Year.ToString)
           End With
       End With

       ’Change in all Custom Layouts in Every Design
        For Each dsgn In curPres.Designs
           For Each lyt In dsgn.SlideMaster.CustomLayouts
                footerState = lyt.HeadersFooters.Footer.Visible
               If footerState = Microsoft.Office.Core.MsoTriState.msoFalse Then lyt.HeadersFooters.Footer.Visible = Microsoft.Office.Core.MsoTriState.msoTrue
                currentFooter = lyt.HeadersFooters.Footer.Text
                lyt.HeadersFooters.Footer.Text = RegularExpressions.Regex.Replace(currentFooter, ”[0-9]{ 4} ”, Date.Now.Year.ToString)
                lyt.HeadersFooters.Footer.Visible = footerState
           Next
       Next

   End Sub