I am trying to add shapes to the slides between sections (with the section number as text in the shape) but I know so far only how to find those with that layout name. I think I should setup a counter somewhere but I have not found a way how. Ideally I would count the sections and then pass the value later to other parts of the macro to be developed.
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
I Set the counter for each slide with Layout Name "Section", then sent the value to the table to be added in those different from those found. So a simple Else
did the trick.
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