View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
David Lloyd[_3_] David Lloyd[_3_] is offline
external usenet poster
 
Posts: 37
Default How do I use VB to set permissions for cell ranges in Excel 2K3?

Chris:

You can use the Users property of the AllowEditRange class to specify the
users. For example:

Public Function AddEditRange()
Dim aer As AllowEditRange

Set aer = ActiveSheet.Protection.AllowEditRanges.Add(Title:= "Range1",
Range:=Range("A1"))
aer.Users.Add "Thomas Jefferson", True

Set aer = Nothing

End Function

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"Chris @ EB" <Chris @ wrote in message
...
I'm trying to use a macro / Visual Basic to select a cell's contents
(contains the Windows user ID) and then set permissions on a specific range
of cells so that only that user can edit the cells. I can do this manually
using ToolsProtection"Allow Users to Edit Ranges . . ." dialog box. But,
I
need to do this for 100 users and repeat it every month, so I'd like to use
a
script. I can define and name the ranges and set the passwords using a
script in Excel, but can't figure out how to access the "Permissions"
settings to specify users. Anyone have any idea?