- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
2#
發表於 2014-7-15 15:01
| 只看該作者
回復 1# yangjie - Option Explicit
- Sub MakeMenu1()
- Dim bar As CommandBarControl
- Dim NewMenu1 As CommandBarControl
- Dim MenuCount As Integer
- Dim i As Integer
- For Each bar In Application.CommandBars(1).Controls
- bar.Visible = False
- Next
- On Error Resume Next
- Application.CommandBars(1).Controls("回主選單").Delete
- On Error GoTo 0
- MenuCount = Application.CommandBars(1).Controls.Count
- Set NewMenu1 = Application.CommandBars(1).Controls.Add(Type:=msoControlPopup, before:=MenuCount, Temporary:=True)
- 'Set NewMenu1 = Application.CommandBars(1).Controls.Add(Type:=10, before:=MenuCount, Temporary:=True)
- With NewMenu1
- .Caption = "回主選單"
- ' .OnAction = "myForm1"
- With .Controls.Add(Type:=msoControlButton)
- .FaceId = 264
- .Caption = "回主選單 A"
- .OnAction = "myForm1"
- End With
- With .Controls.Add(Type:=msoControlButton)
- .FaceId = 207
- .Caption = "回主選單 B"
- .OnAction = "myForm1"
- End With
- End With
- End Sub
複製代碼 |
|