How to add a ribbon button in Adapter for Microsoft Excel?
This sample demonstrates the capability of adding a new ribbon button, along with handling conditional validation and execution of associated action.
In general, using ribbon extensibility following use cases can be achieved
- Add new ribbon elements with custom validations and actions.
- Override existing ribbon control actions and validations.
- Override existing ribbon control icons or strings.
Add-In Extensibility
This sample also demonstrates the capability of tweaking the save routine using the BeforeSave event.
To demonstrate the same, it sets the asset name in the following format:
Enhanced add-in extensibility opens immense possibilities for developers by allowing access to the Application object, also see https://msdn.microsoft.com/en-us/library/office/ff194565.aspx
Developers can register for various native Microsoft Excel events and also programmatically override the Ribbon class.
Configuration
To configure the sample, follow the steps mentioned below:
Update publish version
If published version of the Add-in is already installed then create copy of
Note: If you have changed the published version then in the configuration steps below, wherever specified,
Override the out-of-the-box configuration
- Copy the following file to the <Publish Location>/Application Files/Quark.CMSAdapters.Office.Excel_<Publish Version> folder
Quark.CMSAdapters.Samples.Office.Excel.Extension.dll
Modify the Quark.CMSAdapters.config.deploy file as follows
Add the highlighted content below to the
section: <appSettings> <!-- Other --> <add key="IAddInHostExtension" value="Quark.CMSAdapters.Samples.Office.Excel.Extension" /> <!-- Other --> </appSettings>
Modify the Ribbon.config.deploy file as follows
Add the highlighted content below to the <ribbon> section:
<ribbon> <tabs> <tab idMso="TabHome"> <group id="CMSTabGroupShow" getLabel="GetLabel"> <!-- Other --> <button id="SampleActionId" getImage="GetControlImage" getLabel="GetControlLabel"
getEnabled="IsSampleActionEnabled" onAction="SampleAction" size="large" /> </group> </tab> </tabs> </ribbon>
Update the ClickOnce VSTO installer
Delete <Publish Location>/Application Files/Quark.CMSAdapters.Office.Excel_<Publish Version>/ Quark.CMSAdapters.Office.Excel.vsto file.
Open Visual studio command prompt and run command “Mage” which will open Mage tool
Go to File->Open and select <Publish Location>/Application Files/Quark.CMSAdapters.Office.Excel_<Publish Version>/Quark.CMSAdapters.Office.Excel.dll.manifest file.
Go to “Name” and set version number as specified in the name of Quark.CMSAdapters.Office.Excel.dll.manifest file’s folder.
Go to “Files” and select check box “When populating add the .deploy extension to any file that does not have it” and click on Populate button as shown below
Go to File -> Save and select “Yes” in the Validation dialog as shown below.
Select option “Sign with certificate file” and provide the certificate file and password and click “OK”.
Close Mage tool.
Open Visual studio command prompt and run following command
mage -Update “<Publish Location>/Quark.CMSAdapters.Office.Excel.vsto” -AppManifest “<Publish Location>/Application Files/Quark.CMSAdapters.Office.Excel_<Publish Version>\Quark.CMSAdapters.Office.Excel.dll.manifest” -CertFile “<Certificate Location>\<Certificate>.pfx” -Password “<Password>”Copy the <Publish Location>/Quark.CMSAdapters.Office.Excel.vsto to <Publish Location>/Application Files/Quark.CMSAdapters.Office.Excel_<Publish Version> folder.