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.

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

Figure 2-13. SharePoint creates accounts and notifies new members
| Setting | Permission |
|---|---|
|
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 libraries ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access