How do I protect Excel Workbook Structure except adding new sheets

S

Som_Dev

Hi,
I am exporting some application data to Excel workbook through my C# code.
I would like to Lock the Workbook to prevent users to edit the name of the
sheet and some column data.
But I need to allow user to add new sheet.
Workbook.Protect method allows me to Lock the Structure of the workbook
which includes not allowing to add new sheet.
But As I said I need allow user nothing but adding newworksheet.
How Do I do that ?
 
S

Spiky

Hi,
I am exporting some application data to Excel workbook through my C# code.
I would like to Lock the Workbook to prevent users to edit the name of the
sheet and some column data.
But I need to allow user to add new sheet.
Workbook.Protect method allows me to Lock the Structure of the workbook
which includes not allowing to add new sheet.
But As I said I need allow user nothing but adding newworksheet.
How Do I do that ?

You could create a macro that unprotects the workbook, adds a sheet,
then protects the workbook again. And give the users a button to
operate it. And password protect your VBA so they can't see the
workbook password in your code, which shows as plain text.
 
S

Som_Dev

Hi Spiky,
Thank you very much for your reply. Do you know How to create custom button
in the toolbar of the sheet ?
 
S

Spiky

Hi Spiky,
Thank you very much for your reply. Do you know How to create custom button
in the toolbar of the sheet ?

Toolbar buttons stay with the computer generally, not with the
workbook. So I always make buttons right in a worksheet with the Text
Box drawing tool. This also allows for a real name to show for the
button instead of a tiny picture since the text box can be as large as
you like.

Create a Text Box however you like, I usually add some background
color, rounded corners and shadowing so it looks more like a button.
Right-click on the box and choose Assign Macro. You already have to
have your macro created so you can just pick it from the list. The box
will become clickable, probably with a pointing finger cursor like for
a hyperlink.

Locking the sheet means they cannot mess up the text box/button you
just made.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top