How not to count page numbers for hidden slides in PPT?

孤街醉人 提交于 2020-07-05 03:05:45

问题


In presentation mode, I want only unhidden slides to appear with consecutive page numbers. How can I avoid that hidden slides are counted?


回答1:


Thank you Steve. I found an answer to my question elsewhere. The function below allows you to avoid that hidden slides are interfering with the slide numbers of unhidden slides in presentation mode.

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

In order to avoid that the title slide is numbered insert lngNum = -1 as follows and delete the slide number box in the master title slide.

'check all slides
lngNum = -1
For Each osld In ActivePresentation.Slides



回答2:


In VBA you'd do something like this:

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

In other words, if the SlideShowTransition.Hidden property of the slide is True, don't count it.



来源:https://stackoverflow.com/questions/26362448/how-not-to-count-page-numbers-for-hidden-slides-in-ppt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!