Share via


ListObject.Publish(Object, Boolean) Method

Definition

Publishes the ListObject control to a server that is running Microsoft Windows SharePoint Services.

public:
 System::String ^ Publish(System::Object ^ Target, bool LinkSource);
public string Publish (object Target, bool LinkSource);
abstract member Publish : obj * bool -> string
Public Function Publish (Target As Object, LinkSource As Boolean) As String

Parameters

Target
Object

Contains an array of strings. The following table describes the elements of this array.[1|1] Element#[1|2] Contents[2|1] 0[2|2] URL of SharePoint server.[3|1] 1[3|2] ListName (Display Name).[4|1] 2[4|2] Description of the list.

LinkSource
Boolean

Boolean. (See Remarks section.)

Returns

The URL of the published list on the SharePoint site.

Examples

The following code example creates a ListObject on the current worksheet and then calls the Publish method to publish the ListObject to a Web site that is running Microsoft Windows SharePoint Services. This example assumes that the SharePointURL parameter identifies a valid URL to a Web site running Microsoft Windows SharePoint Services.

This example is for a document-level customization.

private void ListObject_Publish(string SharePointURL)
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(this.Range["A1", "D4"], "Employees");

    // Publish the list object to the SharePoint URL.
    object[] TargetParam = { SharePointURL, "Employees", "Employee data" };
    list1.Publish(TargetParam, false);
}
Private Sub ListObject_Publish(ByVal SharePointURL As String)
    Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
        Me.Controls.AddListObject(Me.Range("A1", "D4"), _
        "Employees")

    ' Publish the list object to the SharePoint URL.
    Dim TargetParam() As Object = {SharePointURL, _
        "Employees", "Employee data"}
    List1.Publish(TargetParam, False)

End Sub

Remarks

If the ListObject control is not currently linked to a list on a SharePoint site, setting LinkSource to true will create a new list on the specified SharePoint site. If the ListObject control is currently linked to a SharePoint site, setting the LinkSource argument to true will replace the existing link (you can only link the list to one SharePoint site). If the ListObject control is not currently linked, setting LinkSource to false will leave the ListObject control unlinked. If the ListObject control is currently linked to a SharePoint site, setting LinkSource to false will keep the ListObject control linked to the current SharePoint site.

Applies to