Overriding Ribbon Buttons not always work

Add-in Express™ Support Service
That's what is more important than anything else

Overriding Ribbon Buttons not always work
 
Alex Maslennikov


Guest


I have an addin that overrides several ribbon buttons. I created new override for SaveObjectAs in Access and it didn't work. I played with initialization order and found that if I move it above some particular spot everything begin to work. Is it a bug or order really matters?

Below is a piece of code:

private void InitializeComponent()
{
....
this.adxAccessEvents = new AddinExpress.MSO.ADXAccessAppEvents(this.components);
this.adxRibbonFileOpen = new AddinExpress.MSO.ADXRibbonCommand(this.components);
this.adxRibbonSaveObjectAs = new AddinExpress.MSO.ADXRibbonCommand(this.components); //this is a trouble one
....
//
// adxRibbonFileOpen
//
this.adxRibbonFileOpen.Id = "adxRibbonCommand_d9242cfd0beb47a8a31812ab18a9e209";
this.adxRibbonFileOpen.IdMso = "FileOpen";
this.adxRibbonFileOpen.Ribbons = ((AddinExpress.MSO.ADXRibbons)((((AddinExpress.MSO.ADXRibbons.msrExcelWorkbook | AddinExpress.MSO.ADXRibbons.msrWordDocument)
| AddinExpress.MSO.ADXRibbons.msrAccessDatabase)
| AddinExpress.MSO.ADXRibbons.msrPowerPointPresentation)));
this.adxRibbonFileOpen.Tag = 2;
this.adxRibbonFileOpen.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.adxRibbonFileOpen_OnAction);
//
// adxRibbonSaveObjectAs
//
this.adxRibbonSaveObjectAs.Id = "adxRibbonCommand_6c0d55500d47421b8e3968d4854d1772";
this.adxRibbonSaveObjectAs.IdMso = "SaveObjectAs";
this.adxRibbonSaveObjectAs.Ribbons = AddinExpress.MSO.ADXRibbons.msrAccessDatabase;
this.adxRibbonSaveObjectAs.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.adxRibbonFileSaveAs_OnAction);
....
}

This is how AddinExpress generated the code. In my case click on "SaveObjectAs" button is never trapped. What I found is that if I manually interchange two lines of code it "magically" works:

private void InitializeComponent()
{
....
this.adxAccessEvents = new AddinExpress.MSO.ADXAccessAppEvents(this.components);
this.adxRibbonSaveObjectAs = new AddinExpress.MSO.ADXRibbonCommand(this.components);
this.adxRibbonFileOpen = new AddinExpress.MSO.ADXRibbonCommand(this.components);
...
}

Thanks!
Posted 13 May, 2010 13:15:53 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Alex,

The root of the problem is that MS Access 2007 doesn't have a Ribbon button with the "FileOpen" id. That is why, MS Access stops handling all subsequent controls that you have in your add-in module once it detects the first error. Please check the
"Show add-in user interface errors" option in the Access Options -> Advanced dialog box to see the error.
Posted 14 May, 2010 08:44:48 Top