我正在尝试仅对特定部分中的幻灯片编号。为此,我需要为每张幻灯片生成编号。假设 first 为该部分中第一张幻灯片的幻灯片编号。然后,该部分中每张幻灯片的编号公式为:
编号=当前幻灯片编号-第一个+ 1
我目前有可以给我当前幻灯片编号的代码(“文本”位于形状内,无需担心)。
.Text = "Add. Info" & vbNewLine & _
ActiveWindow.View.Slide.SlideIndex
我要查找的部分名为AddInfo。
如何获取该部分中第一张幻灯片的幻灯片编号?
答案 0 :(得分:2)
要获取特定部分的第一张幻灯片,可以使用以下功能:
' 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")