Function Reference

_PPT_HeaderFooterSet

Sets the Header/Footer for a Slide/Slides or the SlideMaster/NotesMaster/HandoutMaster/TitleMaster of a Presentation.

#Include <PowerPoint.au3>
_PPT_HeaderFooterSet($oPresentation, $iFlag[, $sFooter = Default[, $sHeader = Default[, $sDateAndTime = Default[, $bSlideNumber = Default[, $vSlides = 0]]]]])

 

Parameters

$oPresentation Presentation object.
$iFlag Processing options. Can be a combination of the following values:
  1 - Set the SlideMaster Footer
  2 - Set the NotesMaster Footer and/or Header
  4 - Set the HandoutMaster Footer and/or Header
  8 - Set the TitleMaster Footer
 16 - Set the Footer for the specified Slide(s)
 32 - Clear Header/Footer information that has been set for individual Slides to make sure all Slides display the Header and information you define for the SlideMaster
 64 - Specifies if the Footer/Header for the Slide(s)/SlideMaster/NotesMaster/HandoutMaster/TitleMaster will be visible
128 - Determines whether the footer, date and time, and slide number appear on the title slide. Applies to slide masters
256 - Updates all existing Slides with the specified Header/Footer settings
$sFooter [optional] Text to use for the Footer. "" will reset the Footer text (default = keyword Default = do not set the Footer).
$sHeader [optional] Text to use for the Header. "" will reset the Header text (default = keyword Default = do not set the Header).
$sDateAndTime [optional] Format for the automatically updated date and time. Use the PpDateTimeFormat enumeration (default = keyword Default = do not set the DateAndTime).
$bSlideNumber [optional] Displays the SlideNumber if set to True (default = keyword Default = do not set the SlideNumber).
$vSlides [optional] Slide(s) to process. Please see _PPT_SlideRangeSet for possible values (default = 0 = all Slides).

 

Return Value

Success: 1.
Failure: 0 and sets @error.
    1 - $oPresentation has to be a presentation
    2 - Error occurred when setting the Footer for the SlideMaster. @extended is set to the COM error code
    3 - Error occurred when setting the Footer/Header for the NotesMaster. @extended is set to the COM error code
    4 - Error occurred when setting the Footer/Header for the HandoutMaster. @extended is set to the COM error code
    5 - Error occurred when setting the Footer for the TitleMaster. @extended is set to the COM error code
    6 - Error occurred when setting the Footer for a SlideRange. @extended is set to the COM error code
    7 - Error returned from _PPT_SetSlideRange. @extended is set to the error code returned by this function
    8 - Error clearing individual Header/Footer information

 

Remarks

CustomLayout and NotesPage can not be processed using this function.
HeaderFooter objects aren't available for Slide objects that represent Notes pages.
The HeaderFooter object that represents a header is available only for a NotesMaster or HandoutMaster.

Parameter $sDateAndTime: https://docs.microsoft.com/en-us/office/vba/api/powerpoint.ppdatetimeformat

See: https://stackoverflow.com/questions/35739457/vba-powerpoint-2010-replacing-text-in-headers-and-footers

 

Related

_PPT_HeaderFooterList

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=N
#include <PowerPoint.au3>
#include <MsgBoxConstants.au3>

; *************************
; Create application object
; *************************
Global $oPPT = _PPT_Open()
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example", "Error creating the PowerPoint application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; ***********************
; Open a presentation
; ***********************
Global $sPresentation = @ScriptDir & "\PresentationHeaderFooter.pptx"
Global $oPresentation = _PPT_PresentationOpen($oPPT, $sPresentation)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example", "Error opening presentation '" & $sPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; ****************************************
; Example 1
; Set the Footer , DateAndTime and
; SlideNumber for Slides 2 and 3
; ****************************************
Global $oSlideRange = _PPT_SlideRangeSet($oPresentation, "2-3")
_PPT_HeaderFooterSet($oPresentation, 16+64, "TestFooter Slides 2-3", Default, $ppDateTimeddddMMMMddyyyy, True, "2-3")
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example 1", "Error setting Footer." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oPresentation.Slides(2).Select
MsgBox($MB_IconInformation,"PowerPoint UDF: _PPT_HeaderFooterSet Example 1", "Footer for Slides 2 and 3 successfully set.")

; ****************************************
; Example 2
; Set the Footer in the SlideMaster
; ****************************************
_PPT_HeaderFooterSet($oPresentation, 1, "SlideMaster TestFooter", Default, Default, True)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example 2", "Error setting Footer." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_IconInformation,"PowerPoint UDF: _PPT_HeaderFooterSet Example 2", "Footer for SlideMaster successfully set.")

; ****************************************
; Example 3
; Set Header/Footer in the NotesMaster
; ****************************************
_PPT_HeaderFooterSet($oPresentation, 2, "NotesMaster TestFooter", "NotesMaster TestHeader", Default, True)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example 3", "Error setting Header/Footer." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_IconInformation,"PowerPoint UDF: _PPT_HeaderFooterSet Example 3", "Header/Footer for NotesMaster successfully set.")

; ****************************************
; Example 4
; Set Header/Footer in the HandoutMaster
; ****************************************
_PPT_HeaderFooterSet($oPresentation, 4, "HandoutMaster TestFooter", "HandoutMaster TestHeader", Default, True)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example 4", "Error setting Header/Footer." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_IconInformation,"PowerPoint UDF: _PPT_HeaderFooterSet Example 4", "Header/Footer for HandoutMaster successfully set.")

; ****************************************
; Example 5
; Clearing all individual Header/Footer information from Slide 2
; ****************************************
_PPT_HeaderFooterSet($oPresentation, 32, Default, Default, 2)
If @error Then Exit MsgBox($MB_ICONERROR, "PowerPoint UDF: _PPT_HeaderFooterSet Example 5", "Error clearing Header/Footer information from Slides." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_IconInformation,"PowerPoint UDF: _PPT_HeaderFooterSet Example 5", "Header/Footer information successfully cleared from the specified Slides.")