Excel2000 VBA 右クリックメニューにマクロを登録 [Excel2000 VBA独習]
Excel2000 VBA 右クリックメニューにマクロを登録
参考にしたサイト(VBA小技集)
http://homepage3.nifty.com/boole/index.htm
http://homepage3.nifty.com/boole/kousure2.htm
参照 「右メニューにマクロを登録したいとき」
コピペ、詳しくは上記サイトにて
Public Sub RightClick()
'右クリックメニューに項目を追加
Dim myRight As CommandBar
'右クリックメニューをオブジェクト変数に代入
Set myRight = Application.CommandBars("Cell")
'右クリックメニューにメニュー追加
With myRight
'1番目に追加
.Controls.Add Type:=msoControlButton, Before:=1
.Controls(1).Caption = "Book情報"
.Controls(1).OnAction = "book_info_2" '←ここにマクロを登録
'2番目に追加
.Controls.Add Type:=msoControlButton, Before:=2
.Controls(2).Caption = "メッセージ-2"
.Controls(2).OnAction = "MsgOut2"
'3番目に追加
.Controls.Add Type:=msoControlButton, Before:=3
.Controls(3).Caption = "メッセージ-3"
.Controls(3).OnAction = "MsgOut2"
'4番目に追加
.Controls.Add Type:=msoControlButton, Before:=4
.Controls(4).Caption = "電卓"
.Controls(4).OnAction = "dentaku"
.Controls(5).BeginGroup = True ’区切り線
End With
End Sub
Sun dentaku() 電卓起動
Shell "calc"
End sub
Public Sub MenuReset()
'右クリックメニューをリセット
Application.CommandBars("Cell").Reset
End Sub
コメント 0