ApplicationFactory.GetVstoObject Method (_Workbook)


Returns a Microsoft.Office.Tools.Excel.Workbook host item that extends the functionality of the specified native workbook object.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Workbook GetVstoObject(
	_Workbook workbook


Type: Microsoft.Office.Interop.Excel._Workbook

The native workbook object for which to retrieve the extended object. Although this parameter is of type Microsoft.Office.Interop.Excel._Workbook, you typically pass a Microsoft.Office.Interop.Excel.Workbook object to this method.

Return Value

Type: Microsoft.Office.Tools.Excel.Workbook

The host item that extends the functionality of the native workbook object.

Call this method in an application-level add-in to customize any workbook that is open in Excel. This method generates a new Microsoft.Office.Tools.Excel.Workbook 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.Workbook object. For more information, see Extending Word Documents and Excel Workbooks in VSTO Add-ins at Run Time.


The workbook parameter is of type Microsoft.Office.Interop.Excel._Workbook, which is the parent interface of Microsoft.Office.Interop.Excel.Workbook. Therefore, this method can accept objects of both types: Microsoft.Office.Interop.Excel._Workbook and Microsoft.Office.Interop.Excel.Workbook. Typically, when you reference an Excel workbook, you use a Microsoft.Office.Interop.Excel.Workbook.

The following code example creates a Microsoft.Office.Tools.Excel.Workbook host item for the active Excel workbook. 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.

Workbook vstoWorkbook =

foreach (SmartTag st in vstoWorkbook.VstoSmartTags)
Return to top