Reputation: 1125
I am trying to number only the slides within a specific section. To do this, I need to generate numbering for each slide. Let first be the slide number of the first slide in that section. Then, the formula for the number of each slide in the section is:
Number = Current slide number - first + 1
I currently have code which gives me the current slide number (the Text is within a shape, no need to worry about that).
.Text = "Add. Info" & vbNewLine & _
ActiveWindow.View.Slide.SlideIndex
The section that I'm looking for is named AddInfo.
How do I get the slide number of the first slide in that section?
Upvotes: 0
Views: 987
Reputation: 19641
To get the first slide of a specific section, you may use the following function:
' Returns the index of the first slide under the section `sectionName`.
' Returns -1 if the section is not found or doesn't have any slides.
Public Function GetFirstSlideNumber(ByVal sectionName As String) As Long
With ActivePresentation.SectionProperties
Dim i As Long
For i = 1 To .Count
If .Name(i) = sectionName Then
GetFirstSlideNumber = .firstSlide(i)
Exit Function
End If
Next
End With
' Section not found.
GetFirstSlideNumber = -1
End Function
Debug.Print GetFirstSlideNumber("AddInfo")
Upvotes: 2