Share via


WorkbookExtensions.GetVstoObject Method

Definition

Overloads

GetVstoObject(_Workbook, ApplicationFactory)

Returns a Workbook host item that extends the functionality of the current Workbook object in an application-level add-in. Pass the Globals.Factory object in your project to the factory parameter.

GetVstoObject(_Workbook, Factory)

Returns a Workbook host item that extends the functionality of the current Workbook object in a document-level customization. Pass the Globals.Factory object in your project to the factory parameter.

GetVstoObject(_Workbook, ApplicationFactory)

Returns a Workbook host item that extends the functionality of the current Workbook object in an application-level add-in. Pass the Globals.Factory object in your project to the factory parameter.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Office::Tools::Excel::Workbook ^ GetVstoObject(Microsoft::Office::Interop::Excel::_Workbook ^ workbook, Microsoft::Office::Tools::Excel::ApplicationFactory ^ factory);
public static Microsoft.Office.Tools.Excel.Workbook GetVstoObject (this Microsoft.Office.Interop.Excel._Workbook workbook, Microsoft.Office.Tools.Excel.ApplicationFactory factory);
static member GetVstoObject : Microsoft.Office.Interop.Excel._Workbook * Microsoft.Office.Tools.Excel.ApplicationFactory -> Microsoft.Office.Tools.Excel.Workbook
<Extension()>
Public Function GetVstoObject (workbook As _Workbook, factory As ApplicationFactory) As Workbook

Parameters

workbook
_Workbook

The native workbook object to extend. Do not supply this parameter yourself. When you call this method on an Excel workbook, the runtime supplies this parameter.

factory
ApplicationFactory

An object that provides access to certain features in your application-level add-in. Pass the Globals.Factory object to this parameter.

Returns

A host item that extends the functionality of the current Workbook object.

Remarks

In an application-level add-in, call this method to extend any workbook that is open in Excel. This method generates a new Microsoft.Office.Tools.Excel.Workbook host item if no such object has already been generated for the Microsoft.Office.Interop.Excel.Workbook object on which you call this method. Subsequent calls to this method on the same Microsoft.Office.Interop.Excel.Workbook object return the same Microsoft.Office.Tools.Excel.Workbook instance.

This method is provided for backward compatibility with Office projects that you retarget from the .NET Framework 3.5 to the .NET Framework 4 or the .NET Framework 4.5. In new projects that target the .NET Framework 4 or the .NET Framework 4.5, you should call the GetVstoObject method that is provided by the Globals.Factory object in your project.

For more information, see Extending Word Documents and Excel Workbooks in VSTO Add-ins at Run Time.

Note

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 extends 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.

Applies to

GetVstoObject(_Workbook, Factory)

Returns a Workbook host item that extends the functionality of the current Workbook object in a document-level customization. Pass the Globals.Factory object in your project to the factory parameter.

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::Office::Tools::Excel::Workbook ^ GetVstoObject(Microsoft::Office::Interop::Excel::_Workbook ^ workbook, Microsoft::Office::Tools::Excel::Factory ^ factory);
public static Microsoft.Office.Tools.Excel.Workbook GetVstoObject (this Microsoft.Office.Interop.Excel._Workbook workbook, Microsoft.Office.Tools.Excel.Factory factory);
static member GetVstoObject : Microsoft.Office.Interop.Excel._Workbook * Microsoft.Office.Tools.Excel.Factory -> Microsoft.Office.Tools.Excel.Workbook
<Extension()>
Public Function GetVstoObject (workbook As _Workbook, factory As Factory) As Workbook

Parameters

workbook
_Workbook

The native workbook object to extend. Do not supply this parameter yourself. When you call this method on an Excel workbook, the runtime supplies this parameter.

factory
Factory

An object that provides access to certain features in your document-level customization. Pass the Globals.Factory object to this parameter.

Returns

A host item that extends the functionality of the current Workbook object.

Remarks

In a document-level customization, you can call this method to get a Microsoft.Office.Tools.Excel.Workbook host item that is in the current customization. If the Microsoft.Office.Interop.Excel.Workbook object on which you call this method is not the underlying object of a Microsoft.Office.Tools.Excel.Workbook host item in the current customization, this method returns null.

This method is provided for backward compatibility with Office projects that you retarget from the .NET Framework 3.5 to the .NET Framework 4 or the .NET Framework 4.5. In new projects that target the .NET Framework 4 or the .NET Framework 4.5, you should call the GetVstoObject method that is provided by the Globals.Factory object in your project. For more information, see Programming Document-Level Customizations.

Note

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 extends 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.

Applies to