|
楼主 |
发表于 2013-7-22 16:56
|
显示全部楼层
- Set NewButton1 = Application.CommandBars("Text").Controls.Add(Type:=msoControlPopup, Before:=1)
- Set NewButton2 = Application.CommandBars("Whole Table").Controls.Add(Type:=msoControlPopup, Before:=1)
- Set NewButton3 = Application.CommandBars("Inline Picture").Controls.Add(Type:=msoControlPopup, Before:=1)
- Set NewButton4 = Application.CommandBars("Floating Picture").Controls.Add(Type:=msoControlPopup, Before:=1)
-
- With NewButton1
- .Caption = "模板菜单" '命令名称
- .Visible = True '可见
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "域与题注"
- .OnAction = "菜单"
- .Visible = True
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "表格设置"
- .OnAction = "菜单"
- .Visible = True
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "图片设置"
- .OnAction = "菜单"
- .Visible = True
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "其他设置"
- .OnAction = "菜单"
- .Visible = True
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "更多功能"
- .OnAction = "菜单"
- .Visible = True
- End With
- End With
- With NewButton2
- '完全一样的代码块
- End With
- With NewButton3
- '完全一样的代码块
- End With
- With NewButton4
- '完全一样的代码块
- End With
- '难道不应该想个办法这样操作吗?
- arr = Array("Text", "Whole Table", "Inline Picture", "Floating Picture")
- For i = LBound(arr) To UBound(arr)
- Set "NewButton" & i + 1 = Application.CommandBars(arr(i)).Controls.Add(Type:=msoControlButton, Before:=1)
- With "NewButton" & i + 1
- '完全一样的代码块
- End With
- Next i
复制代码 |
|