4
votes

I am working on a Excel VSTO 2007 application. I was wondering if there is a way I could disable the Hide and Unhide buttons present in Excel's View tab.

www.i.stack.imgur.com/vLfW5.png

edit: I am looking for a way to do it programatically using c# Code. The old vba might be useful. I have searched a lot and couldn't find any particular solution.

2
you can try setting up a button with matching appearance and ID in your ribbon, not sure if it'll work; Here's the list: microsoft.com/en-us/download/… - Sten Petrov
Cant really believe it!!! didn't you guys se c#, VSTO tags? And i really don't have any code to show here. - Sangram Nandkhile
@Closers: This question is not Off-Topic. Excel programming questions have long been established as On-Topic for SO. - RBarryYoung
Thanks @RBarryYoung: Appreciate that(y) - Sangram Nandkhile

2 Answers

2
votes

I use something like the below to disable the sheet deletion button, perhaps there's something similar for what you want:

Microsoft.Office.Tools.Excel.Worksheet.Worksheet excelShtBase;
excelShtBase.Application.CommandBars["Ply"].Controls["&Delete"].Enabled = false;
1
votes

I don't think you can disable the built-in controls in Excel 2007 and onwards, unless you create your own ribbon bar controls with Ribbon XML.

There're lots of examples or tutorials on MSDN, and here's one for you (Display and Hide Tabs, Groups, and Controls on the Microsoft Office Ribbon).