jeudi 4 février 2016

Loop through all check boxed and add specific slides to array

I would like to make an array (Set Selected_slds = ActivePresentation.Slides.Range) of slides. The slides are to be part of an array that can be selected from a number of Check boxes. So, the idea of the code I would like to write is:

Dim k As Integer
Dim list_of_slides As Array
Dim Selected_slds As SlideRange


For k = 1 To Count(CheckBoxs)
    If CheckBox(k) = True Then
        add.slide(k) to list_of_slides
    End If
Next

Set Selected_slds = list_of_slides

The above is part of a longer code, where Selected_slds is used.

What I have done so far is this:

Sub Test()
Dim oSh As Shape
Dim oSl As Slide
Dim k As Integer

' Look at each shape on each slide in the active pres
For Each oSl In ActivePresentation.Slides
    For Each oSh In oSl.Shapes
        ' Is the shape a control?
        If oSh.Type = msoOLEControlObject Then
            ' Is it a checkbox?
            If InStr(UCase(oSh.OLEFormat.ProgID), "FORMS.CHECKBOX") > 0 Then
                ' BINGO, found what we're after, so ...
                If oSh.OLEFormat.Object.Value = True Then
                    MsgBox "Checked"
                ElseIf oSh.OLEFormat.Object.Value = False Then
                    MsgBox "Uncheked"
                End If
            End If
        End If
    Next ' Shape
Next ' Slide

End Sub

Which works, but I am not sure what to do, to get it to do what I am looking for. It is coded in power point.




Aucun commentaire:

Enregistrer un commentaire