| 
    
     |  | 困ったチャン さん、こんばんわ。 
 >というプログラム文で実行すると5行目から7行目にデバッグがでてとまってしまいます。メニューバーに追加するためのプログラムはどのように直せばいいのですか?回答お願いします。
 
 どんなエラーになったのかわからないので、追加オブジェクトをオブジェクト変数にSet & OnActionに割り当てるマクロ名をフルネームに。なお、割り当てるマクロは標準モジュールにあるものとします。
 
 Sub 伝票入力の追加()
 Dim cp1 As CommandBarPopup
 Dim cb1 As CommandBarButton
 '
 'メニューバーに「伝票入力」を追加
 Set cp1 = Application.CommandBars("Worksheet Menu Bar").Controls.Add(Type:=msoControlPopup, before:=12)
 cp1.Caption = "伝票入力"
 cp1.BeginGroup = True '一応区切り線を入れておく
 '追加 Button1
 Set cb1 = cp1.Controls.Add(Type:=msoControlButton)
 cb1.Caption = "入金伝票"
 cb1.OnAction = ThisWorkbook.Name & "!入金伝票を表示"
 '追加 Button2
 Set cb1 = cp1.Controls.Add(Type:=msoControlButton)
 cb1.Caption = "出金伝票"
 cb1.OnAction = ThisWorkbook.Name & "!出金伝票を表示"
 '追加 Button3
 Set cb1 = cp1.Controls.Add(Type:=msoControlButton)
 cb1.Caption = "振替伝票"
 cb1.OnAction = ThisWorkbook.Name & "!振替伝票を表示"
 '開放
 Set cb1 = Nothing: Set cp1 = Nothing
 End Sub
 
 こんな感じです。
 
 |  |