循环显示所有复选框并将特定幻灯片添加到数组

时间:2016-02-04 08:44:07

标签: if-statement checkbox foreach powerpoint-vba

我想制作幻灯片的数组(Set Selected_slds = ActivePresentation.Slides.Range)。幻灯片将成为可从多个复选框中选择的阵列的一部分。所以,我想写的代码的想法是:

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

以上是较长代码的一部分,其中使用了Selected_slds。

到目前为止,我所做的是:

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

哪个有效,但我不知道该怎么做,让它去做我想要的。它以功率点编码。

0 个答案:

没有答案