Click here to Skip to main content
15,038,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a winform application that contains an excel viewer in one of its forms.It lets user to open and modify excel files. but i want to avoid users to create any new sheets,
so i need to know :

How can i get rid of the last tab of workbook tabs that allows user to add new sheet?[^](I have tried a lot to insert the image of the button here but the code project editor convert < and > characters to something else.However i can see my image in preview panel very well!!!!)

I have found the following code to unvisible the button in the above image:
ExcelViewer1.Application.CommandBars["Workbook tabs"].Controls["Sheet List"].Visible = false;

But it thrown a COMException : "Error HRESULT E_FAIL has been returned from a call to a com component".

The same command works for other commandbars like Ply, Cell.
Updated 25-May-13 19:42pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900