运行时错误' -2147352567(80020009)'指定集合的​​索引超出范围

时间:2017-07-04 18:39:59

标签: vba checkbox

我定期运行错误: 运行时错误' -2147352567(80020009)' 指定集合的​​索引超出范围。

该错误抛出

  

对于每个cb在wks.Shapes

以下是完整代码:

Sub SelectAll(wks As Worksheet)
Application.ScreenUpdating = False
Dim cb As Shape

'Loop through Checkboxes
  For Each cb In wks.Shapes
    If cb.Type = msoFormControl Then
      If cb.FormControlType = xlCheckBox Then
        cb.OLEFormat.Object.Value = xlOn
        With cb.OLEFormat.Object
            Application.Run .OnAction, .Name
        End With
      End If
    End If
  Next cb
Application.ScreenUpdating = True
End Sub

0 个答案:

没有答案