作業を効率化してくれるソフト/サイトを提供します

【ppt】Addin登録

アドイン作成するソースコードを示します。
メルマガと連動していますので、必要に応じてご確認をお願いします。

‘メニューで選択して実行するマクロ1(メルマガ 2016/7/26)
Sub Message1()
MsgBox “メッセージ1を表示”
End Sub

‘メニューで選択して実行するマクロ2(メルマガ 2016/7/26)
Sub Message2()
MsgBox “メッセージ2を表示”
End Sub

‘アドオン追加時に自動でToolBarを追加する
Sub Auto_Open()

‘ツールバー制御用のオブジェクト変数(メルマガ 2016/7/27)
Dim NewControl As CommandBarControl

‘ツールバーに1つ目のメニュー登録(メルマガ 2016/7/27)
Set NewControl = Application.CommandBars(“Tools”).Controls.Add _
(Type:=msoControlButton)

‘メニューのプロパティ設定(2016/7/27)
NewControl.Caption = “マクロ1”
NewControl.FaceId = 59 ‘ニコニコ
NewControl.OnAction = “Message1”

‘オブジェクト解放(次を登録するので)(メルマガ 2016/7/27)
Set NewControl = Nothing

‘ツールバーに2つ目のメニュー登録(メルマガ 2016/7/28)
Set NewControl = Application.CommandBars(“Tools”).Controls.Add _
(Type:=msoControlButton)

‘メニューのプロパティ設定(2016/7/28)
NewControl.Caption = “マクロ2”
NewControl.FaceId = 60 ‘??
NewControl.OnAction = “Message2”

‘オブジェクト解放(次を登録するので)(メルマガ 2016/7/28)
Set NewControl = Nothing

End Sub

‘アドオン削除時に自動でToolBarを削除する(メルマガ 2016/7/29)
Sub Auto_Close()

‘ツールバー制御用のオブジェクト変数(メルマガ 2016/7/29)
Dim oControl As CommandBarControl

‘追加したツールバーを探して、削除実行(メルマガ 2016/7/29)
For Each oControl In Application.CommandBars(“Tools”).Controls

‘ Check to see whether the comand exists.
If oControl.Caption = “マクロ1” Then
‘ Check to see whether action setting is set to ChangeView.
If InStr(oControl.OnAction, “Message1”) > 1 Then ‘デバッグ時はこちら
‘If oControl.OnAction = “Message1” Then
‘ Remove the command from the menu.
oControl.Delete
End If

‘ Check to see whether the comand exists.
ElseIf oControl.Caption = “マクロ2” Then
‘ Check to see whether action setting is set to ChangeView.
If InStr(oControl.OnAction, “Message2”) > 1 Then ‘デバッグ時はこちら
‘If oControl.OnAction = “Message2” Then
‘ Remove the command from the menu.
oControl.Delete
End If
End If

Next oControl

End Sub

PAGETOP
Copyright © FFT project ~時間制約からの解放~ All Rights Reserved.
Powered by WordPress & BizVektor Theme by Vektor,Inc. technology.