- 帖子
- 91
- 主題
- 5
- 精華
- 0
- 積分
- 130
- 點名
- 2
- 作業系統
- Win10
- 軟體版本
- Office 2010
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2016-5-14
- 最後登錄
- 2026-6-21
|
回復 5# mhl9mhl9
參考看看- Public Const B1 As String = "text-B1"
- Public Const B2 As String = "text-B2"
- Public Const B3 As String = "text-B3"
- Public Sub abc()
- With Application.CommandBars.Add("測試", msoBarTop, , True)
- .Visible = True
- With .Controls.Add(Type:=msoControlPopup) '參數代入數字
- .Caption = "測試1"
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試0"
- .OnAction = "text" '沒代入參數
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試1-1"
- .OnAction = "'text 1'" '代入參數會在原本最外圍的雙引號裡面分別加單引號
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試1-2"
- .OnAction = "'text 1,2'" '不同參數用逗號分開
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試1-3"
- .OnAction = "'text 1,2,3'"
- End With
- End With
- With .Controls.Add(Type:=msoControlPopup) '參數代入文字
- .Caption = "測試2"
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試2-1"
- .OnAction = "'text ""B1""'" '文字左右側分別加上兩個雙引號
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試2-2"
- .OnAction = "'text ""B1"",""B2""'"
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試2-3"
- .OnAction = "'text ""B1"",""B2"",""B3""'"
- End With
- End With
- With .Controls.Add(Type:=msoControlPopup) '參數代入變數
- .Caption = "測試3"
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試3-1"
- .OnAction = "'text B1'"
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試3-2"
- .OnAction = "'text B1,B2'"
- End With
- With .Controls.Add(Type:=msoControlButton)
- .Caption = "測試3-3"
- .OnAction = "'text B1,B2,B3'"
- End With
- End With
- End With
- End Sub
- Public Sub text(Optional Arg1 = "A1", Optional Arg2 = "A2", Optional Arg3 = "A3") '預設沒代入參數的預設值
- MsgBox Arg1 & Chr(10) & Chr(13) & Arg2 & Chr(10) & Chr(13) & Arg3
- End Sub
複製代碼 |
|