How to hide Ribbon Tab - Group - Button - Menu in SharePoint 2010? But why? because, the requirement is: Users to fill the form and not upload any existing documents to the document libraries in a particular site. So wanted to disable Upload Document button from SharePoint ribbon.
![hide sharepoint ribbon button hide sharepoint ribbon button]()
Solution:
Override the existing SharePoint 2010 Ribbon Tab/Group/Button/Menu by creating an empty CommandUIDefinition!
Steps in Detail:
1. Create an empty SharePoint 2010 farm solution project in Visual Studio 2010. Give it a name. Say, Crescent.TeamSites.HideUploadButton.
![sharepoint hide ribbon items sharepoint hide ribbon items]()
2. Add a new "Empty Element" item to the project. This will create a Feature with Elements.xml file.
![hide sharepoint ribbon tab hide sharepoint ribbon tab]()
3. Update the Elements.xml file with below content.
![hide a ribbon button in sharepoint 2010 hide a ribbon button in sharepoint 2010]()
4. Now, Go to Feature designer, Name the Feature Title & Description. Specify the scope as Web and Include the Element to the feature.
![sharepoint 2010 hide button from ribbon sharepoint 2010 hide button from ribbon]()
5. Deploy the feature and see the result in action.
![hide a ribbon button in sharepoint 2010 hide a ribbon button in sharepoint 2010]()
Here the Location is the key. For all available location values, refer MSDN: http://msdn.microsoft.com/en-us/library/ee537543%28v=office.14%29.aspx
Tips: You can also use IE Toolbar/Firebug to get the location ID! (Take the text till - Hyphen )
![sharepoint ribbon hide tab sharepoint ribbon hide tab]()
Hiding SharePoint 2010 Ribbon Tabs, Groups, Button Menus
The above method applies when you want to hide button menus from the Ribbon.
How to Hide Ribbon Tab - Group - Button - Menu on a Particular List?
While its possible to target custom action to List types, Content Types, File Types, There is no way to target on specific list declaratively! So, we can get it done programmatically. Here is how to hide ribbon buttons in SharePoint 2010 programmatically:
To remove the custom action use this code:
Hide Ribbon Button by CSS:
We can hide ribbon buttons using CSS also. Refer my post for more info: How to Disable Multiple File Upload in SharePoint
Microsoft KB: http://support.microsoft.com/kb/2285182

Solution:
Override the existing SharePoint 2010 Ribbon Tab/Group/Button/Menu by creating an empty CommandUIDefinition!
Steps in Detail:
1. Create an empty SharePoint 2010 farm solution project in Visual Studio 2010. Give it a name. Say, Crescent.TeamSites.HideUploadButton.

2. Add a new "Empty Element" item to the project. This will create a Feature with Elements.xml file.

3. Update the Elements.xml file with below content.
<?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/"><CustomAction Id="RemoveRibbonButton" Location="CommandUI.Ribbon"><CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location="Ribbon.Documents.New.AddDocument" /></CommandUIDefinitions></CommandUIExtension></CustomAction></Elements>

4. Now, Go to Feature designer, Name the Feature Title & Description. Specify the scope as Web and Include the Element to the feature.

5. Deploy the feature and see the result in action.

Here the Location is the key. For all available location values, refer MSDN: http://msdn.microsoft.com/en-us/library/ee537543%28v=office.14%29.aspx
Tips: You can also use IE Toolbar/Firebug to get the location ID! (Take the text till - Hyphen )

Hiding SharePoint 2010 Ribbon Tabs, Groups, Button Menus
The above method applies when you want to hide button menus from the Ribbon.
- E.g. Hide "Upload Multiple Documents" Menu link under "Upload" button, specify the location as: Ribbon.Documents.New.AddDocument.Menu.Upload.UploadMultiple
- To Hide Ribbon Tabs, E.g. Hide Documents tab in document library ribbon, the location should be "Ribbon.Document".
- Similarly to hide Ribbon Tab Button Groups, E.g. "New" group in SharePoint Ribbon, specify the location as: Ribbon.Documents.New
How to Hide Ribbon Tab - Group - Button - Menu on a Particular List?
While its possible to target custom action to List types, Content Types, File Types, There is no way to target on specific list declaratively! So, we can get it done programmatically. Here is how to hide ribbon buttons in SharePoint 2010 programmatically:
static void Main(string[] args) { using (SPSite site = new SPSite("http://sharepoint.crescent/")) using (SPWeb web = site.OpenWeb()) { //Get the "Projects" List SPList list = web.Lists.TryGetList("Projects"); if (list != null) { var action = list.UserCustomActions.Add(); action.Location = "CommandUI.Ribbon"; action.Sequence = 50; action.Title = "Hide Upload Button from Ribbon"; action.CommandUIExtension = @" <CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""Ribbon.ListItem.New""></CommandUIDefinition></CommandUIDefinitions></CommandUIExtension>"; action.Update(); } } }
To remove the custom action use this code:
using (SPSite site = new SPSite("http://sharepoint.crescent.com/")) using (SPWeb web = site.OpenWeb()) { //Get the "Projects" List SPList list = web.Lists.TryGetList("Projects"); if (list != null) { foreach (SPUserCustomAction action in list.UserCustomActions) { if (action.Title == "Hide Upload Button from Ribbon") { action.Delete(); break; } } } }
Hide Ribbon Button by CSS:
We can hide ribbon buttons using CSS also. Refer my post for more info: How to Disable Multiple File Upload in SharePoint
Microsoft KB: http://support.microsoft.com/kb/2285182