SSブログ

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


Excel_VBA_rightclick_2.jpg


タグ:Excel2000 VBA
nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。