在演示模式下,我希望只有未连接的幻灯片显示连续的页码。如何避免计算隐藏的幻灯片?
答案 0 :(得分:4)
谢谢史蒂夫。我在其他地方找到了我的问题的答案。下面的功能可以避免隐藏的幻灯片在演示模式下干扰未隐藏幻灯片的幻灯片编号。
Sub Number_NonHidden()
'For v.2007 onwards only
Dim osld As Slide
Dim objSN As Shape
Dim lngNum As Long
'check all slides
For Each osld In ActivePresentation.Slides
'Is it hidden
If osld.SlideShowTransition.Hidden Then
osld.HeadersFooters.SlideNumber.Visible = False
Else
osld.HeadersFooters.SlideNumber.Visible = True
Set objSN = getNumber(osld)
lngNum = lngNum + 1
If Not objSN Is Nothing Then ' there is a number placeholder
objSN.TextFrame.TextRange = CStr(lngNum + 1)
End If
End If
Next osld
End Sub
Function getNumber(thisSlide As Slide) As Shape
For Each getNumber In thisSlide.Shapes
If getNumber.Type = msoPlaceholder Then
If getNumber.PlaceholderFormat.Type = ppPlaceholderSlideNumber Then
'it's the slide number
Exit Function
End If
End If
Next getNumber
End Function
为避免标题幻灯片编号,请插入lngNum = -1,如下所示,并删除主标题幻灯片中的幻灯片编号框。
'check all slides
lngNum = -1
For Each osld In ActivePresentation.Slides
答案 1 :(得分:0)
在VBA中你会做这样的事情:
Sub CountSlides()
Dim oSl As Slide
Dim x As Long
For Each oSl In ActivePresentation.Slides
If Not oSl.SlideShowTransition.Hidden Then
x = x + 1
End If
Next
MsgBox x
End Sub
换句话说,如果幻灯片的SlideShowTransition.Hidden属性为True,请不要计算它。