Spreadsheet cell protection with c#

T

texlnghorn

I am trying to setup my Spreadsheet so that only certain cells are protected.
I can protect my entire active Spreadsheet by specifying:
axSpreadsheet1.ActiveSheet.Protection.Enabled = true;

Is there a way to set up a range of cells to protect? What I really want to
do is protect the first n columns as these correspond to display values only.
I then want to unprotect the remaining columns as these correspond to
editable values. I am using C# to program my OWC Spreadsheet application.

Thanks,
Mike
 
T

texlnghorn

Alvin,
Thanks for your reply. I'm looking at the Range object but I don't see a
Protect method. There is a Worksheet method that I can protect but it seems
to protect the entire worksheet and not the Range.

-Mike
 
T

texlnghorn

I figured out my problem. I first needed to unlock the range of cells I want
to make editable and then Protect the entire worksheet.

myrange.set_Locked(false);
sp.ActiveWorkSheet.Protection.Enabled = true;

Thanks,
Mike

texlnghorn said:
Alvin,
Thanks for your reply. I'm looking at the Range object but I don't see a
Protect method. There is a Worksheet method that I can protect but it seems
to protect the entire worksheet and not the Range.

-Mike

Alvin Bruney said:
the range object contains a protect method that you can use to protect the
selected range

--

________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------
 

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