Handling Excel File Checkout and File Discard Checkout Event using ADXRibbonCommand

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

Only registered users are allowed to subscribe.
Handling Excel File Checkout and File Discard Checkout Event using ADXRibbonCommand
For a Excel file on SharePoint server, how to handle File Checkout and File Discard Checkout 
Subscribe
Amit B




Posts: 33
Joined: 2013-09-13
The below-given code piece does not work for IdMSO "FileCheckOutDiscard". The method gets executed if I change IdMso value to "FileSave". However, it does not work for "FileCheckOutDiscard". I have verified this with excel 2010 and 2016.

//
// adxRibbonCommand1
//
this.adxRibbonCommand1.Id = "adxRibbonCommand_ac762bcd03404ab1b5e5294c7b374288";
this.adxRibbonCommand1.IdMso = "FileCheckOutDiscard";
this.adxRibbonCommand1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
this.adxRibbonCommand1.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.AdxRibbonCommand1_OnAction);

private void AdxRibbonCommand1_OnAction(object sender, IRibbonControl control, bool pressed, ADXCancelEventArgs e)
{
MessageBox.Show("Hello World");
}

the control "FileCheckOutDiscard" is mentioned as "Not in the ribbon" button. So, is there any other way to handle this event or if I need to fix the given code in any way.
Posted 16 May, 2019 13:16:30 Top
Andrei Smolin


Add-in Express team


Posts: 16162
Joined: 2006-05-11
Hello Amit,

What do I do to have this control visible and enabled in the Excel UI? How do you know that this IdMso represents the control that you click? Did you check this using the Customize ribbon dialog as explained at https://www.add-in-express.com/creating-addins-blog/2013/06/21/customizing-builtin-office-ribbon-groups/?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 May, 2019 02:29:01 Top
Amit B




Posts: 33
Joined: 2013-09-13
The attached link says "Another caveat, for which there is no workaround, is that the Office Ribbon offers very little control over how controls are aligned and how they react to the horizontal resizing of the host Office window."

Does it mean that it is not possible to implement "Discard CheckOut" button in Excel Ribbon (button is visible For SharePoint files)?
Posted 17 May, 2019 04:21:46 Top
Andrei Smolin


Add-in Express team


Posts: 16162
Joined: 2006-05-11
What do you mean by "implement"? I've added that control to a custom group using the Customize Ribbon dialog. That means, you can show it using code. In my case, the control is disabled; I assume this is because I don't have a SharePoint file.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 May, 2019 04:37:13 Top
Amit B




Posts: 33
Joined: 2013-09-13
I tried using the customize ribbon to use "FileCheckOutDiscard" idmso as mentioned in the link https://www.add-in-express.com/creating-addins-blog/2013/06/21/customizing-builtin-office-ribbon-groups/?. However, I was not able to capture any SharePoint event using this.

Is it possible for you to provide me with any sample which implements handling idmso such as "FileCheckOut", "FileCheckIn", and "FileCheckOutDiscard" using adx.

Thanks
Posted 22 May, 2019 00:35:48 Top
Andrei Smolin


Add-in Express team


Posts: 16162
Joined: 2006-05-11
Hello Amit,

The InitializeComponent() method below describes the components and settings of a test add-in.

        #region Component Designer generated code
        /// <summary>
        /// Required by designer support - do not modify
        /// the following method
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.adxRibbonCommand1 = new AddinExpress.MSO.ADXRibbonCommand(this.components);
            this.adxRibbonCommand2 = new AddinExpress.MSO.ADXRibbonCommand(this.components);
            // 
            // adxRibbonCommand1
            // 
            this.adxRibbonCommand1.Id = "adxRibbonCommand_3fdc30ac38c54ce5b64494d864abc2dd";
            this.adxRibbonCommand1.IdMso = "FileCheckOut";
            this.adxRibbonCommand1.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
            this.adxRibbonCommand1.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.adxRibbonCommand1_OnAction);
            // 
            // adxRibbonCommand2
            // 
            this.adxRibbonCommand2.Id = "adxRibbonCommand_535ba36ecdd048ebb58f17372f594594";
            this.adxRibbonCommand2.IdMso = "FileCheckOutDiscard";
            this.adxRibbonCommand2.Ribbons = AddinExpress.MSO.ADXRibbons.msrExcelWorkbook;
            this.adxRibbonCommand2.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.adxRibbonCommand2_OnAction);
            // 
            // AddinModule
            // 
            this.AddinName = "MyAddin86";
            this.SupportedApps = AddinExpress.MSO.ADXOfficeHostApp.ohaExcel;

        }
        #endregion

        private AddinExpress.MSO.ADXRibbonCommand adxRibbonCommand1;
        private AddinExpress.MSO.ADXRibbonCommand adxRibbonCommand2;


The code below shows how I handle clicking the buttons specified by the ADXRibbonCommand components above:

private void adxRibbonCommand1_OnAction(object sender, IRibbonControl control, bool pressed, ADXCancelEventArgs e)
{
    MessageBox.Show("adxRibbonCommand1_OnAction. IdMso = '" + (sender as ADXRibbonCommand).IdMso + "'");
}

private void adxRibbonCommand2_OnAction(object sender, IRibbonControl control, bool pressed, ADXCancelEventArgs e)
{
    MessageBox.Show("adxRibbonCommand2_OnAction. IdMso = '" + (sender as ADXRibbonCommand).IdMso + "'");
}


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 May, 2019 06:01:54 Top
Amit B




Posts: 33
Joined: 2013-09-13
Hello Andrei Smolin,

I tried to use the code provided by you in your last reply. However, it seems like that the IDMSO such as "FileSave", "FileClose" are working fine but nothing happens for "FileCheckOut" or "FileCheckOutDiscard". I am using excel 2016 and 2010 to test this. I checked-out/discarded check-out using the buttons visible in File Menu and from the website.
Posted 23 May, 2019 04:11:13 Top
Andrei Smolin


Add-in Express team


Posts: 16162
Joined: 2006-05-11
Hello Amit,

You need to check the IdMso of the buttons that you use.

In my case, I've used the Customize Ribbon dialog to put the buttons FileCheckOut and FileCheckOutDiscard onto a custom Ribbon group. Then I tested the add-in by pressing these buttons.

Amit B writes:
However, I was not able to capture any SharePoint event using this.


I assume you talk about Outlook events, not SharePoint events, correct?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 May, 2019 06:22:31 Top