Share via


WorksheetExtensions.HasVstoObject Method

Definition

Overloads

HasVstoObject(_Worksheet, ApplicationFactory)

Returns a value that indicates whether a Worksheet host item has been created for the current Worksheet object in an application-level add-in. Pass the Globals.Factory object in your project to the factory parameter.

HasVstoObject(_Worksheet, Factory)

Returns a value that indicates whether a Worksheet host item has been created for the current Worksheet object in a document-level customization. Pass the Globals.Factory object in your project to the factory parameter.

HasVstoObject(_Worksheet, ApplicationFactory)

Returns a value that indicates whether a Worksheet host item has been created for 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 bool HasVstoObject(Microsoft::Office::Interop::Excel::_Worksheet ^ worksheet, Microsoft::Office::Tools::Excel::ApplicationFactory ^ factory);
public static bool HasVstoObject(this Microsoft.Office.Interop.Excel._Worksheet worksheet, Microsoft.Office.Tools.Excel.ApplicationFactory factory);
static member HasVstoObject : Microsoft.Office.Interop.Excel._Worksheet * Microsoft.Office.Tools.Excel.ApplicationFactory -> bool
<Extension()>
Public Function HasVstoObject (worksheet As _Worksheet, factory As ApplicationFactory) As Boolean

Parameters

worksheet
_Worksheet

The native worksheet object to test. 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

true if a Worksheet host item has been created for the current Worksheet object; otherwise, false.

Remarks

In an application-level add-in, you can call this method to determine whether a Microsoft.Office.Tools.Excel.Worksheet host item exists for any Microsoft.Office.Interop.Excel.Worksheet object. Typically, you use this method to test for the existence of managed controls that you want to persist before closing or saving an Excel worksheet.

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

HasVstoObject(_Worksheet, Factory)

Returns a value that indicates whether a Worksheet host item has been created for 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 bool HasVstoObject(Microsoft::Office::Interop::Excel::_Worksheet ^ worksheet, Microsoft::Office::Tools::Excel::Factory ^ factory);
public static bool HasVstoObject(this Microsoft.Office.Interop.Excel._Worksheet worksheet, Microsoft.Office.Tools.Excel.Factory factory);
static member HasVstoObject : Microsoft.Office.Interop.Excel._Worksheet * Microsoft.Office.Tools.Excel.Factory -> bool
<Extension()>
Public Function HasVstoObject (worksheet As _Worksheet, factory As Factory) As Boolean

Parameters

worksheet
_Worksheet

The native worksheet object to test. 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

true if a Worksheet host item has been created for the current Worksheet object; otherwise, false.

Remarks

In a document-level customization, this method returns true only if the Microsoft.Office.Interop.Excel.Worksheet object on which you call this method is the underlying object of a Microsoft.Office.Tools.Excel.Worksheet host item in the current customization. Otherwise, this method returns false.

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 HasVstoObject 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