LoginSignup
13
13

More than 5 years have passed since last update.

VBAで作ったアドインをリボン付で配布する

Posted at

VBAで作ったファイルをリボン付でアドイン化する

前提1:ExcelのVBAに、IRibbonControl型のパラメーターを唯一の引数とする関数は_eventhandlerを接尾語として記述する

Public Sub MainHtmlReading_eventhandler(control As IRibbonControl)
  Htmlreader
End Sub

'呼出し関数の本体
Public Sub Htmlreader()
  'VBAの処理    
 End Sub

前提2:ExcelのVBAを特定のブックに依存しない形で作成し、xlam形式(Excelアドイン)で保存する

ツールのダウンロード

Custom UI EditorによるRibbonパーツ編集

  1. インストーラーによりスタートメニューに登録されているので、スタートメニューから「Custom UI Editor for Microsoft Office」を起動する

  2. File>Openからあらかじめ作ったxlamファイルを呼び出す

  3. Menu Insert>'Office2010 Custom UI part' を実行することで、customUI**.xmlが追加される

  4. 次のxmlを下のxmlへコピーして必要に応じて名前を書き換える

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab id="customTab" label="TestCase" insertAfterMso="TabHome">
                <group id="customGrp" label="Compiler" imageMso="MailMergeResultsPreview" autoScale="true">
                <button id="SeleniumBuilder" label="SeleniumIDE" imageMso="ViewSheetGridlines" onAction="MainHtmlReading_eventhandler" visible="true" size="large"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>
  1. File>Save により保存する

さらに、マクロ時実行時にセキュリティの警告ができないようにアドインを配置する

  1. ファイル>オプション>セキュリティセンター>セキュリティセンターの設定... からセキュリティセンターを呼び出す
  2. 「信頼できる場所」から適当な場所にxlamファイルをコピーする

そして、アドオンを登録する

  1. ファイル>オプション>アドインにて「管理(A)」でExcelアドインが表示されていることを確認の上、「設定...」をクリック
  2. 「参照(B)...」でxlamファイルを登録する
13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13