Я изменил код, найденный в pptalchemy, чтобы добавить гибкие номера слайдов в соответствии с моими требованиями. Я пытаюсь пропустить добавление номеров слайдов для слайдов, которые имеют форму с именем тега «Том» и значением тега «Джерри». Мне было интересно, есть ли способ сделать это.
Sub Numberme()
'Copyright PowerPoint alchemy
'Numbers consecutively from a start slide but does not number title slides if requested
'enter 999 to remove numbers
On Error GoTo errhandler
Dim lFrom As Long, lTot As Long, lNum As Long, n As Long
Dim sngLeftpos As Single, strTask As String
Dim osld As Slide, oShp As Shape
lFrom = CInt(InputBox("start numbering from slide ...?"))
If lFrom <> 999 Then strTask = MsgBox("Number Title layout slides?", vbYesNo)
lNum = 1
lTot = ActivePresentation.Slides.Count
'strip old numbers
For Each osld In ActivePresentation.Slides
For Each oShp In osld.Shapes
If oShp.Name = "snumber" Then oShp.Delete
Next oShp
Next osld
'main routine
sngLeftpos = 775.6
If lFrom = 999 Then Exit Sub
If lFrom > lTot Then
MsgBox "You have chosen a start point > than the number of slides!", vbCritical, "Error"
Exit Sub
End If
For n = lFrom To lTot
With ActivePresentation.Slides(n).Shapes.AddTextbox(msoTextOrientationHorizontal, _
Left:=sngLeftpos, _
Top:=566.4, _
Width:=30, _
Height:=50)
.TextFrame.TextRange.Characters.Font.Size = 7
.TextFrame.TextRange.Font.Color.RGB = RGB(116, 116, 128)
.TextFrame.TextRange.ParagraphFormat.Bullet.Visible = False
.TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignRight
.TextFrame.TextRange.Lines.ParagraphFormat.SpaceWithin = 9
If strTask = vbNo And ActivePresentation.Slides(n).Shapes(1).Tags("Tom") = "Jerry" Then
' don't number the slide but increment the slide number
' comment the following line out if you want title slides to be skipped
' ie, not to be included in numbering sequence and not numbered
lNum = lNum + 1
Else
.TextFrame.TextRange.Text = CStr(lNum)
.Name = "snumber"
lNum = lNum + 1
End If
End With
Next
Exit Sub
errhandler:
MsgBox "Sorry there's an error!", vbCritical
End Sub