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?
Edit :
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
We can disable the functionality of sheet insert tab by doing something like this
workbook.Protect(Type.Missing, true, true);
also you could take a look at the following link Check this link
Hope this helps
Well, you may try this Link to add control to your Workbook then
add a sheet using this piece of code
Excel.Worksheet newWorksheet;
newWorksheet = (Excel.Worksheet)Globals.ThisWorkbook.Worksheets.Add(
missing, missing, missing, missing);
hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.