OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Sections

A section is a logical grouping of sequential slides. This is a new feature in PPT 2010. You can add/edit/delete a section in the thumbnail or slide sorter view. The sections can be collapsed, renamed, dragged and dropped. This feature is fully supported in the object model with the new SectionProperties object.

Supported versions: PowerPoint 2010

'Count number of sections in presentation
With ActivePresentation.SectionProperties
      Debug.Print "Sections: " & .Count

' Enumerate the section info
For I = 1 To .Count
     Debug.Print "Section ID: " & .SectionID(I)
     Debug.Print "Section Name: " & .Name(I)
     Debug.Print "Number of Slides in section: " & .SlidesCount(I)

   ' Note: -1 indicates that the section has no slides in it.
     Debug.Print .FirstSlide(I)
Next

' Add a new section at the start
Call ActivePresentation.SectionProperties.AddSection(1, "Start")

' You can also add a section before a specific slide (4th in this case).
' It will return the section number if successful
' Note: If the presentation has no sections and you try to add a section at some slide other than the 1st one
' then PowerPoint will add 2 sections. One at the beginning of the presentation as well as the one at the
' specified location


Debug.Print .AddBeforeSlide(4, "Test Section")

'Delete sections but not the slides
For I = .Count To 1 Step -1
   Call .Delete(I, False)
Next

' Move the 2nd section to 1
' Note: All slides in the section are moved

Call .Move(2, 1)

End With

' Section properties associated with slides

' Which section does this slide belong to?
' Note: Returns 1 if no sections are present

Debug.Print ActivePresentation.Slides(7).sectionIndex

' Move the 1st slide to the beginning of the 2nd section
Call ActivePresentation.Slides(1).MoveToSectionStart(2)

' Section properties associated with document window

' Expand the 2nd section if it is collapsed.
' Note: Thumbnail view or slide sorter view must be active
' Presentation should have sections

If Not ActiveWindow.IsSectionExpanded(2) Then Call ActiveWindow.ExpandSection(2, True)

 

 


Copyright 1999-2014 (c) Shyam Pillai. All rights reserved.