如何使用计数将形状添加到部分之间的幻灯片

How to add Shapes to Slides between Sections with Counting

我正在尝试将形状添加到各部分之间的幻灯片(部分编号作为形状中的文本),但到目前为止我只知道如何找到具有该布局名称的那些。我想我应该在某个地方设置一个柜台,但我还没有找到方法。 理想情况下,我会计算这些部分,然后将值传递给要开发的宏的其他部分。

Sub Navigator()

Dim oSlide As Slide
Dim oSlideNavigator As Slide
Dim oShapeNavigator As Shape
Dim Section_N As Integer



    For Each oSlide In ActivePresentation.Slides
        If oSlide.CustomLayout.Name = "Section" Then
        Set oShapeNavigator = oSlide.Shapes.AddTable(2, 2, Left:=10, Top:=10, Width:=200, Height:=2)
            oShapeNavigator.Fill.ForeColor.RGB = RGB(255, 128, 128)

        End If
    Next
End Sub
 

我为布局名称为“Section”的每张幻灯片设置计数器,然后将值发送到 table 以添加到与找到的不同的幻灯片中。所以一个简单的 Else 就成功了。

Sub NavigatorX()

'Dim SectionXArr() As Long
Dim oSlide As Slide

Dim SectionX As Slide
Dim SectionXArr As SlideRange ' was ReDim
Dim oShapeNavigator As Shape
Dim NavSlide As Slide
Dim nCounter As Long
'Dim NavSlides

Dim iRow As Integer
Dim iColumn As Integer

For Each oSlide In ActivePresentation.Slides

    If oSlide.CustomLayout.Name = "Section" Then
        nCounter = nCounter + 1
        
        ElseIf nCounter > 0 Then
            Set oShapeNavigator = oSlide.Shapes.AddTable(1, 1, Left:=10, Top:=10, Width:=200, Height:=2)
        oShapeNavigator.Fill.ForeColor.RGB = RGB(255, 128, 128)
        With oShapeNavigator.Table

            For iRow = 1 To .Rows.Count
            For iColumn = 1 To .Columns.Count
                    With .Cell(iRow, iColumn).Shape.TextFrame.TextRange
                        .Text = "Section " & nCounter
                    With .Font
                        .Name = "Bahnschrift SemiBold Condensed (Headings)"
                        .Size = "14"
                    End With
                    End With
            Next iColumn
            Next iRow
        End With

        
    End If

Next oSlide

End Sub