Protect a worksheet and allow edit of a range in OWC

E

Eric

I am developing a web application in ASP.NET which generates an Excel
spreadsheet using OWC10. I would like to enable protection, and open
up a range of cells to allow editing. I know how to protect the sheet
(using the ActiveSheet.Protect method), but it doesn't appear that
there is any way to allow a user to edit a range. I know that Excel
PIA exposes the AllowEditRanges property, but I don't see an
equivalent in OWC. Any assistance would be much appreciated.

Eric
 
E

Edwin Ortega

Hello Eric,

You can set up your OWC instance to allow editing to a group of users
autheticated with the Windows Security. All you have to do is protect
the worksheet, and the select an editable range with a collection of
allowed users. here is an example:

Sub AddEditRange()

Dim erScenarioEditRanges As AllowEditRanges
Dim erFinanceInputs As AllowEditRange

' Add an edit range to the Scenarios worksheet.
Set erFinanceInputs = _
Worksheets("Scenarios").Protection.AllowEditRanges.Add(Title:=
_
"Finanacial Scenario Inputs", Range:=Worksheets("Scenarios")
_
.Range("E1:G15"), Password:="ecnanif")

' Add Andrew Dixon to the list of users who can change the
' edit range. By setting the AllowEdit argument to False,
' Andrew must enter the designated password in order to make
' changes to the edit range.
erFinanceInputs.Users.Add Name:="Andrew Dixon", AllowEdit:=False

' Add Stephanie Hooper to the list of users who can change the
' edit range.
erFinanceInputs.Users.Add Name:="Stephanie Hooper", AllowEdit:=True

' Protect the Scenarios worksheet. Allow users to format and sort
cells.
Worksheets("Scenarios").Protect Password:="OpenSesame", _
DrawingObjects:=True, _
Contents:=True, Scenarios:=True, _
AllowSorting:=True,
AllowFiltering:=True

End Sub


Hope this helps,
Edwin
 

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