Excel VBA - creating your own toolbar

If you are faced with the task of automating something in excel, then forget about the macros located directly in the book, create a toolbar (ribbon), which



  1. does not depend on a specific file
  2. located in the main toolbar
  3. gives a customizable UI


image



In order to create such a panel, you will need



1) an excel file with the xlam extension located in% userprofile% \ appdata \ roaming \ microsoft \ addins



2) an xml resource editor (for labeling buttons)



image



3) define buttons by example



button id="b_MemberSelect" label="Member Select"    onAction="p_MemberSelect" imageMso="ReturnToTaskList"  size="large" 


where p_MemberSelect is a VBA procedure



4) in the initialization of the procedure (in the xlam file), you need to pass the predefined parameters

Sub p_MemberSelect (ByVal vIRibbonControl As IRibbonControl)



But this solution has one limitation - it is not possible to create forms embedded in the Excel panel, for example:



image



This example from an In2Sql project (an Excel plugin that renders SQL objects) . In this plugin, the code is generated using c # and VSTO libraries.



All Articles