Class SectionProperties (PowerPoint VBA)

Contains properties and methods for manipulating sections in a presentation.

To use a SectionProperties class variable it first needs to be instantiated, for example

Dim sps as SectionProperties
Set sps = ActivePresentation.SectionProperties

SectionProperties class variables can be set using the Presentation.SectionProperties procedure.

AddBeforeSlide

Adds a section immediately before the specified slide index, and returns the index of the new section.

The indices of sections after the newly inserted section are automatically incremented by one. If a section break exists immediately before the specified slide index, the new section is placed after the section break, with the result that the preceding section is now empty, and the specified slide index is now the first slide of the new section. If the presentation does not contain any sections and you call this method, passing a SlideIndex value greater than 1, a new section is created before the first slide and given the default section name.

AddBeforeSlide (SlideIndex, sectionName)

Dim lngSlideIndex As Long: lngSlideIndex = 
Dim strsectionName As String: strsectionName = 
Dim lngAddBeforeSlide As Long
lngAddBeforeSlide = ActivePresentation.SectionProperties.AddBeforeSlide(SlideIndex:=lngSlideIndex, sectionName:=strsectionName)

Arguments

The following arguments are required:

SlideIndex (Long) - The index of the slide before which to add the section.

sectionName (String) - The name of the new section.

AddSection

Adds a new section at the specified index position and returns the index of the newly created section.

If a section already exists at the specified index position, calling AddSection is equivalent to adding an empty section immediately before that section. The indices of sections after the newly inserted section are automatically incremented by one. sectionIndex can be one larger than the total number of existing sections, as long as it is less than the maximum number of sections allowed (512); this creates a new, empty section at the end. If no sections exist in the presentation, calling this method and passing a sectionIndex value of 1 creates the first section.

AddSection (sectionIndex, sectionName)

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim lngAddSection As Long
lngAddSection = ActivePresentation.SectionProperties.AddSection(sectionIndex:=lngsectionIndex)

Arguments

The following argument is required

sectionIndex (Long) - The index of the section before which to add the section.

Optional arguments

The following argument is optional

sectionName (String) - The name of the new section.

Count

Returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.SectionProperties.Count

Delete

Deletes the section break that sets off the specified section, and optionally deletes all the slides in the section.

If the presentation contains more than one section, you cannot delete the first section without deleting all of the slides in that section.

Delete (sectionIndex, deleteSlides)

Dim lngsectionIndex As Long: lngsectionIndex = 
ActivePresentation.SectionProperties.Delete sectionIndex:=lngsectionIndex, deleteSlides:=True

Arguments

The following arguments are required:

sectionIndex (Long) - The index of the section to delete.

deleteSlides (Boolean) - Whether to delete all the slides in the section. True, to delete all the slides within the section; False not to delete them.

FirstSlide

Returns the index of the first slide in the specified section, or returns -1 if the section is empty.

FirstSlide (sectionIndex)

sectionIndex: The index of the section.

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim lngFirstSlide As Long
lngFirstSlide = ActivePresentation.SectionProperties.FirstSlide(sectionIndex:=lngsectionIndex)

Move

Moves the specified section to the specified index position, moving the slides in the section along with the section break.

The section is moved to the index position immediately before the section whose current index is toPos.

Move (sectionIndex, toPos)

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim lngtoPos As Long: lngtoPos = 
ActivePresentation.SectionProperties.Move sectionIndex:=lngsectionIndex, toPos:=lngtoPos

Arguments

The following arguments are required:

sectionIndex (Long) - The index of the section to move.

toPos (Long) - The index position to which to move the section.

Name

Returns the name of the specified section as a String.

Name (sectionIndex)

sectionIndex: The index of the section in the SectionProperties collection.

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim strName As String
strName = ActivePresentation.SectionProperties.Name(sectionIndex:=lngsectionIndex)

Rename

Renames the specified section with the specified name.

If sectionName is empty, the section is assigned the default section name.

Rename (sectionIndex, sectionName)

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim strsectionName As String: strsectionName = 
ActivePresentation.SectionProperties.Rename sectionIndex:=lngsectionIndex, sectionName:=strsectionName

Arguments

The following arguments are required:

sectionIndex (Long) - The index of the section to rename.

sectionName (String) - The new name of the section.

SectionID

Returns a string that represents the unique identifier of the specified section.

The returned string is in the form "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX}", where each "X" is a hexadecimal digid.

SectionID (sectionIndex)

sectionIndex: The index of the section.

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim strSectionID As String
strSectionID = ActivePresentation.SectionProperties.SectionID(sectionIndex:=lngsectionIndex)

SlidesCount

Returns the number of slides in the specified section.

SlidesCount (sectionIndex)

sectionIndex: The index of the section.

Dim lngsectionIndex As Long: lngsectionIndex = 
Dim lngSlidesCount As Long
lngSlidesCount = ActivePresentation.SectionProperties.SlidesCount(sectionIndex:=lngsectionIndex)