Hiding Multiple Ribbon Buttons

For a particular Form Library I was interested in making it difficult to do too much with the Forms except add them. I employed a range of measures, one of which was to hide the ribbon buttons for Sharing or opening with Explorer View. 

This can be done by creating a customAction and deploying it to your site. Some of this is documented elsewhere, but I noticed that there were no examples showing multiple buttons hiding - the examples showed a single instance. Also the examples always showed a "RegistrationId" of 101, without explaining that this targeted Document Libraries. To target Form Libraries I had to dig up the fact that "RegistrationId" of Form Libraries is 115.

The xml looks like this;

<?xmlversion="1.0"encoding="utf-8"?>

<Elementsxmlns="http://schemas.microsoft.com/">

  <CustomAction

    Id="RemoveRibbonButton"

    Location="CommandUI.Ribbon"

    RegistrationId="115"

    RegistrationType="List">

    <CommandUIExtension>

      <CommandUIDefinitions>

        <CommandUIDefinitionLocation="Ribbon.Library.Actions.OpenWithExplorer" />

        <CommandUIDefinitionLocation="Ribbon.Library.Actions.ExportToSpreadsheet" />

        <CommandUIDefinitionLocation="Ribbon.Library.Actions.OpenWithAccess" />

        <CommandUIDefinitionLocation="Ribbon.Library.Share.ViewRSSFeed" />

        <CommandUIDefinitionLocation="Ribbon.Library.Share.AlertMe" />

        <CommandUIDefinitionLocation="Ribbon.Library.Share.EmailLibraryLink" />

        <CommandUIDefinitionLocation="Ribbon.Library.Actions.TakeOfflineToClient" />

        <CommandUIDefinitionLocation="Ribbon.Library.Actions.ConnectToClient" />

      </CommandUIDefinitions>

    </CommandUIExtension>

  </CustomAction>

 

</Elements>

 

To get this into your site, create an empty SharePoint project in Visual Studio. A sandboxed solution is fine. Add a feature to the project, and paste the above XML into the Elements.xml file. Smallest scope for the feature is Web.

Build and add the WSP to your Solution Gallery via Site Collection Settings. When activated, and the Feature activated in a given Web, it will hide the named buttons in all Form Libraries in the current SPWeb.

Here's a list of other elements you could hide using the above method; http://msdn.microsoft.com/en-us/library/ee537543(v=office.14).aspx

Mike Smith kindly documented the many Registration IDs for different libraries here; http://techtrainingnotes.blogspot.ch/2008/01/sharepoint-registrationid-list-template.html

Happy SharePointing!

Disclaimer: The software, source code and guidance on this website is provided "AS IS"
with no warranties of any kind. The entire risk arising out of the use or
performance of the software and source code is with you.

Any views expressed in this blog are those of the individual and may not necessarily reflect the views of any organization the individual may be affiliated with.