Add Users and Permissions

If you read the previous topic, you saw sample code using the Members collection, but so far we haven’t added any members to the workspace. The user who creates the workspace is automatically a member, of course, but you can add other members and set their permissions either through the SharePoint site, through the Excel task pane, or through code.

How to do it

SharePoint provides an easy-to-use interface for adding users and setting permissions, as shown in Figures 2-12 and 2-13.

Excel provides a similar interface if you click Add new member on the Shared Workspace task pane. To add users from code, use the Members collection’s Add method:

   Set sw = ThisWorkbook.SharedWorkspace
   If sw.Connected Then
       sw.Members.Add "ExcelDemo@hotmail.com", "APPTIX\ExcelDemo", _
   "Contributor"
   End If

The last argument of the Add method sets the users’ permissions, as shown in the following table.

Click Add new member and SharePoint displays this form

Figure 2-12. Click Add new member and SharePoint displays this form

SharePoint creates accounts and notifies new members

Figure 2-13. SharePoint creates accounts and notifies new members

SettingPermission

Guest

No access by default, but can be granted access to specific items.

Reader

Read-only access to the site.

Contributor

Add content to existing document libraries and lists.

Web designer

Create lists and document ...

Get Excel 2003 Programming: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.