我定期运行错误: 运行时错误' -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