Amandine FAURILLOU
Amandine FAURILLOU

Reputation: 612

Ignore hidden slides when printing a table of contents in VBA - Powerpoint

I am trying to write a table of contents at the begining of my powerpoint presentation.

The code I have fetches all the slide that have a title, and print them along with their index.

I would like to know where can I find the command to determine wether or not a slide is hidden. I have searched the msdn VBA Powerpoint section, but came up empty.

For example, my current project is :

For y = 3 To ActivePresentation.Slides.Count
Set Diapo = ActivePresentation.Slides(y)
'si la diapo a un titre
If Diapo.Shapes.HasTitle Then
Set titre = Diapo.Shapes.Title
texte_ajout = texte_ajout & Format(y, "0 - ") & titre.TextFrame. _
TextRange.Text & Chr(13) & vbCrLf
End If
Next y

It counts all of the slides, including those that might be hidden.

I would like (if it is possible) to write this before the first if and after the set Diapo

If Diapo.SlideShowTransition.Hidden = msoTrue Then
Set counthidden = counthidden + 1

...

texte_ajout = texte_ajout & Format(y-counthidden, "0 - ") & titre.TextFrame. _
TextRange.Text & Chr(13) & vbCrLf
End If

(I defined counthidden as byte first, then as long, but it's not working) Is it possible?

Upvotes: 1

Views: 485

Answers (1)

R3uK
R3uK

Reputation: 14537

Here you go ;)

For y = 3 To ActivePresentation.Slides.Count
    Set Diapo = ActivePresentation.Slides(y)
    If Diapo.SlideShowTransition.Hidden = msoTrue Then 'other value : msoFalse
        CountHidden = CountHidden + 1
    Else
        'The slide is not hidden
        If Diapo.Shapes.HasTitle Then
            'si la diapo a un titre
            Set titre = Diapo.Shapes.Title
            texte_ajout = texte_ajout & Format(y - CountHidden, "0 - ") & titre.TextFrame. _
                TextRange.Text & Chr(13) & vbCrLf
        End If
    End If
Next y

Upvotes: 2

Related Questions