我希望能够将按钮存储在某种集合中,比如ArrayList,
以便我可以动态地添加和删除。我尝试使用Collection,但当ar.Add()被调用时出现错误。
对象不支持此属性或方法。
Public Sub removeAllFormsWithAdd()
Dim myshape As Shape
Dim ar As Collection
For Each myshape In ActiveSheet.Shapes
If (myshape.FormControlType = xlButtonControl) Then
If (myshape.TextFrame.Characters.Text = "name") Then
ar.Add (myshape)
Debug.Print "next shape:" & myshape.TextFrame.Characters.Text & "-"
End If
End If
Next myshape
End Sub
我该如何获取它?