以OLEObjects.Add方法加入Checkbox控制項,
若要刪除工作表內之前加入的Checkbox,該如何寫呢?
Dim OB As OLEObject
For Each OB In ActiveSheet.OLEObjects
If OB.progID = "Forms.checkbox.1" Then OB.Delete
Next作者: GBKEE 時間: 2012-4-20 13:28
程式碼 "Forms.Checkbox.1"已是大寫但還是無法清除原先的控制項,請大大幫我看看!
Private Sub CommandButton1_Click()
Dim x As Integer
Dim xxx As String
Dim yyy As String
Dim OB As OLEObject
x = UserForm1.ComboBox1.Value
Range("G1").Value = x
For i = 10 To 200
xxx = i
Range("A" & xxx).Value = ("")
Range("B" & xxx).Value = ("")
Range("C" & xxx).Value = ("")
Next
ActiveSheet.Range("A10:F200").Borders.LineStyle = XILinestyleNone
For j = 1 To x
yyy = 9 + j
Range("C" & yyy).Value = j
Next
For Each OB In ActiveSheet.OLEObjects
If OB.progID = "Forms.Checkbox.1" Then OB.Delete
Next
n = 1
For Each a In Range("C:C").SpecialCells(xlCellTypeConstants)
For k = 1 To 3
Select Case k
Case "1"
MyStr = n & "功能性需求"
Case "2"
MyStr = n & "感官性需求"
Case "3"
MyStr = n & "隱藏性需求"
End Select
With a.Offset(, k)
Set OB = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Checkbox.1", Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)
OB.Object.Caption = MyStr
OB.Object.GroupName = n
End With
Next
n = n + 1
Next
End Sub作者: oobird 時間: 2012-4-24 15:07
For Each g In ActiveSheet.Shapes
If g.Name Like "Group*" Then g.Delete
Next
刪群組作者: GBKEE 時間: 2012-4-24 16:08
回復 3#caichen3
Forms.CheckBox.1 大小寫要ㄧ致
看看 哪裡不一樣
If OB.progID = "Forms.Checkbox.1" Then OB.Delete作者: caichen3 時間: 2012-4-24 16:15