|
发表于 2011-4-24 16:18
|
显示全部楼层
本楼为最佳答案
- Sub test()
- Dim pop As CommandBarPopup
- Dim cmb As CommandBarButton
- Dim mc As CommandBarControl
- Dim mb As Shape, n As Long, rng As Range
- For Each mc In CommandBars("学习").Controls
- Select Case TypeName(mc)
- Case "CommandBarPopup"
- For Each cmb In mc.Controls
- GoSub SettingControls
- Next
- Case "CommandBarButton":
- Set cmb = mc
- GoSub SettingControls
- End Select
- Next
- Exit Sub
- SettingControls:
- n = n + 1
- Set rng = Cells(n * 2, "H")
- Dim mk As Shape
- For Each mk In Sheet3.Shapes
- If mk.TextFrame.Characters.Text = cmb.Caption Then mk.Delete
- Next
- Set mb = Sheet3.Shapes.AddFormControl(xlButtonControl, Left:=rng.Left, Top:=rng.Top, Width:=50, Height:=30)
- mb.TextFrame.Characters.Text = cmb.Caption
- mb.OnAction = cmb.OnAction
- Return
- End Sub
复制代码
详见附件!
|
评分
-
查看全部评分
|