Search code examples
c#ms-accessvstoadd-in

How to add a custom control to a menubar in an ms-access VBE-Add-in?


I wrote an Add-in for the VBA-Editor of MS Aaccess in C# How to write a Add-in for the development enviroment: "Microsoft Visual Basic for Applications"

I already created a toolbar like this:

var toolbar = m_VBE.CommandBars.Add(RadToolbarCaption, MsoBarPosition.msoBarTop, System.Type.Missing, true);

As I need a more sophisticated control (a dropDown list with icons inside) in the toolbar I thought of adding a custom control to the toolbar. This is what I tried:

try
{
    var crtl = m_toolbar.Controls.Add(MsoControlType.msoControlCustom);
}
catch (Exception ex)
{
    Debug.WriteLine(ex.Message);
}   

But this returns an ArgumentException:

Value outside of the valid range (Original: "Der Wert liegt außerhalb des erwarteten Bereichs.")

Is there a way to add a control other than the few standard controls to the menuebar?


Solution

  • No, it's not possible to use non-standard controls in an Office CommandBar object.