Name

listobject.Publish(Target, LinkSource)

Synopsis

Shares a worksheet list on a SharePoint server. Returns a string containing the address of the list on the Web.

Argument

Settings

Target

The full address of the SharePoint server to share the list on. Includes the http: protocol identifier and the name of any subwebs.

LinkSource

True links the contents of the worksheet list to the SharePoint list for synchronization. False copies the list to the SharePoint server, but does not link the contents.

The following code shares a list on a worksheet and displays the location of the list once it is shared:

Sub ShareList(  )
    Dim ws As Worksheet, lst As ListObject
    Dim str As String, dest(2) As Variant
    Set ws = ActiveSheet
    Set lst = ws.ListObjects("Test List")
    dest(0) = "http://www.excelworkshop.com"
    dest(1) = "Test List"
    dest(2) = "A description goes here..."
    str = lst.Publish(dest, True)
    ' Display the shared list in the browser.
    ThisWorkbook.FollowHyperlink str
End Sub

The name of the list (Test List in preceding code) must be unique within the SharePoint site. If a list with that name already exists, an error occurs and the list is not shared.

Get Programming Excel with VBA and .NET 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.