Section 2.10.Share a List


2.10. Share a List

Excel calls sharing a list publishing . When a list is published, SharePoint Services creates a new item in the Lists folder that teammates can use to view or modify the list's data (Figure 2-23).

2.10.1. How to do it

To publish a list in Excel, select the list and then choose Data List Publish List. Excel displays a series of steps that publish the list on the SharePoint server and display the address for the shared list (Figure 2-24).

To publish a list from code, use the ListObject's Publish method. The first argument of the Publish method is a three-element string array containing the address of the SharePoint server, a unique name for the list, and an optional description of the list. For example, the following code publishes a list created previously:

    Set lst = ws.ListObjects("Excel Objects")    Dim str As String    Dim dest(2) As Variant    dest(0) = SPSITE    dest(1) = "Excel Objects"    dest(2) = "Excel objects listed by date introduced"    str = lst.Publish(dest, True)    MsgBox "Your list has been shared. You can view it at: " & str

Figure 2-23. A published list


The Publish method returns a string containing the address of the published list. The preceding code displays that address in a message box, but you may want to navigate to that address or include a link to it somewhere on the sheet.

To add a hyperlink to the list on the SharePoint server, add a hyperlink to a range:

    Dim lnk As Hyperlink    Set lnk = ws.Hyperlinks.Add(Range("C2"), str)

After adding the hyperlink, you can display the web page for the list by using the Follow method:

    lnk.Follow

The ListObject's SharePointURL property returns the address of the list, so it is easy to get the address of the shared list after it has been created:

    str = ws.ListObjects("Excel Objects").SharePointURL    Set lnk = ws.Hyperlinks.Add(Range("C2"), str, , _      "Click to display list site.", "View")

Figure 2-24. Steps in publishing a list


2.10.2. How it works

SharePoint Services stores lists as XML files. You can edit or link to a list through its SharePoint page, or you can use the SharePoint Lists web service to access the list directly through code.

Lists reflect a range of cells within a workbook, rather than the entire workbook file itself. By sharing only the germane range of cells, you avoid publishing the underlying data and macros, which lends to security and also to the utility of the shared data. The shared list can then be included in different workbooks used by others.

Access to lists is administered in the same way as for shared workspaces. If the list is shared at the root level of the site, all users of the site have access to the list. If the list is shared as part of a workspace, only workspace members have access.

The main limitation of lists is that they can be shared only through Windows Server 2003 running SharePoint Services. That's because the sharing and maintenance of lists is provided through the ASP.NET active server pages and web services that SharePoint provides. Other types of network shares are simply not supported.



    Excel 2003 Programming. A Developer's Notebook
    Excel 2003 Programming: A Developers Notebook (Developers Notebook)
    ISBN: 0596007671
    EAN: 2147483647
    Year: 2004
    Pages: 133
    Authors: Jeff Webb

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net