|
- Private Sub CommandButton1_Click()
- Dim cbms As OLEObject
- Dim ShtCodeName As String
- ShtCodeName = Sheet2.CodeName
- Set cbms = Sheet2.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, _
- DisplayAsIcon:=False, Left:=0.75, Top:=298.5, Width:=108)
- ' ActiveSheet.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, _
- ' DisplayAsIcon:=False, Left:=1277.25, Top:=146.25, Width:=108, Height _
- ' :=18.75).Select
- With cbms
- ' .Object.Caption = Mid(.Name, 9)
- .Height = 22.5
- '.Width = .TopLeftCell.Width
- .Width = 100
-
- .Object.ForeColor = RGB(255, 255, 255)
- .Enabled = True
- .Object.BackColor = RGB(2, 114, 192)
- .Top = 100.5 + (Mid(.Name, 9) - 1) * .Height
- .Left = 1000
- .Object.Font.Name = "微软雅黑"
- .Object.Font.Size = 11
- .Object.Font.Bold = True
- End With
-
- With ThisWorkbook.VBProject.VBComponents.Item(ShtCodeName).CodeModule
- .InsertLines 1, "Private Sub " & cbms.Name & "_Click()"
- .InsertLines 2, "msgbox ""生成事件成功"""
- .InsertLines 3, "'这是一个注释示例"
- .InsertLines 4, "End Sub"
- End With
- ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule).Name = "模块6"
- End Sub
复制代码
你好,我这样添加模块 ,怎么提示我 add无法作用于vbccomponents,这句哪里错了吗 |
|