Share via


WorksheetExtensions.GetVstoObject Method

Definition

Overloads

GetVstoObject(_Worksheet, ApplicationFactory)

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

GetVstoObject(_Worksheet, Factory)

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

GetVstoObject(_Worksheet, ApplicationFactory)

Returns a Worksheet host item that extends the functionality of the current Worksheet 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::Worksheet ^ GetVstoObject(Microsoft::Office::Interop::Excel::_Worksheet ^ worksheet, Microsoft::Office::Tools::Excel::ApplicationFactory ^ factory);
public static Microsoft.Office.Tools.Excel.Worksheet GetVstoObject (this Microsoft.Office.Interop.Excel._Worksheet worksheet, Microsoft.Office.Tools.Excel.ApplicationFactory factory);
static member GetVstoObject : Microsoft.Office.Interop.Excel._Worksheet * Microsoft.Office.Tools.Excel.ApplicationFactory -> Microsoft.Office.Tools.Excel.Worksheet
<Extension()>
Public Function GetVstoObject (worksheet As _Worksheet, factory As ApplicationFactory) As Worksheet

Parameters

worksheet
_Worksheet

The native worksheet object to extend. Do not supply this parameter yourself. When you call this method on an Excel worksheet, 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 Worksheet object.

Remarks

In an application-level add-in, call this method to extend any worksheet that is open in Excel. This method generates a new Microsoft.Office.Tools.Excel.Worksheet host item if no such object has already been generated for the Microsoft.Office.Interop.Excel.Worksheet object on which you call this method. Subsequent calls to this method on the same Microsoft.Office.Interop.Excel.Worksheet object return the same Microsoft.Office.Tools.Excel.Worksheet 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 worksheet parameter is of type Microsoft.Office.Interop.Excel._Worksheet, which is the parent interface of Microsoft.Office.Interop.Excel.Worksheet. Therefore, this method extends both types: Microsoft.Office.Interop.Excel._Worksheet and Microsoft.Office.Interop.Excel.Worksheet. Typically, when you reference an Excel worksheet, you use a Microsoft.Office.Interop.Excel.Worksheet.

Applies to

GetVstoObject(_Worksheet, Factory)

Returns a Worksheet host item that extends the functionality of the current Worksheet 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::Worksheet ^ GetVstoObject(Microsoft::Office::Interop::Excel::_Worksheet ^ worksheet, Microsoft::Office::Tools::Excel::Factory ^ factory);
public static Microsoft.Office.Tools.Excel.Worksheet GetVstoObject (this Microsoft.Office.Interop.Excel._Worksheet worksheet, Microsoft.Office.Tools.Excel.Factory factory);
static member GetVstoObject : Microsoft.Office.Interop.Excel._Worksheet * Microsoft.Office.Tools.Excel.Factory -> Microsoft.Office.Tools.Excel.Worksheet
<Extension()>
Public Function GetVstoObject (worksheet As _Worksheet, factory As Factory) As Worksheet

Parameters

worksheet
_Worksheet

The native worksheet object to extend. Do not supply this parameter yourself. When you call this method on an Excel worksheet, 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 Worksheet object.

Remarks

In a document-level customization, you can call this method to get a Microsoft.Office.Tools.Excel.Worksheet host item that is in the current customization. If the Microsoft.Office.Interop.Excel.Worksheet object on which you call this method is not the underlying object of a Microsoft.Office.Tools.Excel.Worksheet 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 worksheet parameter is of type Microsoft.Office.Interop.Excel._Worksheet, which is the parent interface of Microsoft.Office.Interop.Excel.Worksheet. Therefore, this method extends both types: Microsoft.Office.Interop.Excel._Worksheet and Microsoft.Office.Interop.Excel.Worksheet. Typically, when you reference an Excel worksheet, you use a Microsoft.Office.Interop.Excel.Worksheet.

Applies to