Partilhar via


ApplicationFactory.GetVstoObject Method (ListObject)

Returns a Microsoft.Office.Tools.Excel.ListObject that extends the functionality of the specified native list object.

Namespace:  Microsoft.Office.Tools.Excel
Assemblies:   Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Function GetVstoObject ( _
    listObject As ListObject _
) As ListObject
ListObject GetVstoObject(
    ListObject listObject
)

Parameters

Return Value

Type: Microsoft.Office.Tools.Excel.ListObject
The object that extends the functionality of the native list object.

Remarks

Call this method in an application-level add-in to customize any list object in an Excel worksheet. This method generates a new Microsoft.Office.Tools.Excel.ListObject object if no such object has already been generated. Subsequent calls to this method return the cached instance of the existing Microsoft.Office.Tools.Excel.ListObject object. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.

Examples

The following code example creates a Microsoft.Office.Tools.Excel.ListObject host item. To use this code, run it from the ThisAddIn class in an Excel add-in project that targets the .NET Framework 4 or the .NET Framework 4.5.

Dim mySheet As Excel.Worksheet = Me.Application.ActiveSheet
If mySheet.ListObjects.Count > 0 Then 
    Dim vstoListObject As ListObject = _
        Globals.Factory.GetVstoObject(mySheet.ListObjects(1))

    vstoListObject.SetDataBinding(ds, "Product", "Name")
End If
Excel.Worksheet mySheet = (Excel.Worksheet)
    this.Application.Worksheets["Sheet1"];
if (mySheet.ListObjects.Count > 0)
{
    ListObject vstoListObject =
        Globals.Factory.GetVstoObject(mySheet.ListObjects[1]);

    vstoListObject.SetDataBinding(ds, "Product", "Name");
}

.NET Framework Security

See Also

Reference

ApplicationFactory Interface

GetVstoObject Overload

Microsoft.Office.Tools.Excel Namespace

Other Resources

Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time

Programming Document-Level Customizations