How not to count page numbers for hidden slides in PPT?
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 onlyDim osld As SlideDim objSN As ShapeDim lngNum As Long'check all slidesFor Each osld In ActivePresentation.Slides'Is it hiddenIf osld.SlideShowTransition.Hidden Thenosld.HeadersFooters.SlideNumber.Visible = FalseElseosld.HeadersFooters.SlideNumber.Visible = TrueSet objSN = getNumber(osld)lngNum = lngNum + 1If Not objSN Is Nothing Then ' there is a number placeholderobjSN.TextFrame.TextRange = CStr(lngNum + 1)End IfEnd IfNext osldEnd SubFunction getNumber(thisSlide As Slide) As ShapeFor Each getNumber In thisSlide.ShapesIf getNumber.Type = msoPlaceholder ThenIf getNumber.PlaceholderFormat.Type = ppPlaceholderSlideNumber Then'it's the slide numberExit FunctionEnd IfEnd IfNext getNumberEnd 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 slideslngNum = -1For Each osld In ActivePresentation.Slides
In VBA you'd do something like this:
Sub CountSlides()Dim oSl As SlideDim x As LongFor Each oSl In ActivePresentation.Slides If Not oSl.SlideShowTransition.Hidden Then x = x + 1 End IfNextMsgBox xEnd Sub
In other words, if the SlideShowTransition.Hidden property of the slide is True, don't count it.