WorkbookExtensions.HasVstoObject Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
HasVstoObject(_Workbook, ApplicationFactory) |
Returns a value that indicates whether a Workbook host item has been created for the current Workbook object in an application-level add-in. Pass the Globals.Factory object in your project to the |
HasVstoObject(_Workbook, Factory) |
Returns a value that indicates whether a Workbook host item has been created for the current Workbook object in a document-level customization. Pass the Globals.Factory object in your project to the |
HasVstoObject(_Workbook, ApplicationFactory)
public:
[System::Runtime::CompilerServices::Extension]
static bool HasVstoObject(Microsoft::Office::Interop::Excel::_Workbook ^ workbook, Microsoft::Office::Tools::Excel::ApplicationFactory ^ factory);
public static bool HasVstoObject (this Microsoft.Office.Interop.Excel._Workbook workbook, Microsoft.Office.Tools.Excel.ApplicationFactory factory);
static member HasVstoObject : Microsoft.Office.Interop.Excel._Workbook * Microsoft.Office.Tools.Excel.ApplicationFactory -> bool
<Extension()>
Public Function HasVstoObject (workbook As _Workbook, factory As ApplicationFactory) As Boolean
Parameters
- workbook
- _Workbook
The native workbook object to test. 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
true
if a Workbook host item has been created for the current Workbook object; otherwise, false
.
Remarks
In an application-level add-in, you can call this method to determine whether a Microsoft.Office.Tools.Excel.Workbook host item exists for any Microsoft.Office.Interop.Excel.Workbook 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 workbook.
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
HasVstoObject(_Workbook, Factory)
public:
[System::Runtime::CompilerServices::Extension]
static bool HasVstoObject(Microsoft::Office::Interop::Excel::_Workbook ^ workbook, Microsoft::Office::Tools::Excel::Factory ^ factory);
public static bool HasVstoObject (this Microsoft.Office.Interop.Excel._Workbook workbook, Microsoft.Office.Tools.Excel.Factory factory);
static member HasVstoObject : Microsoft.Office.Interop.Excel._Workbook * Microsoft.Office.Tools.Excel.Factory -> bool
<Extension()>
Public Function HasVstoObject (workbook As _Workbook, factory As Factory) As Boolean
Parameters
- workbook
- _Workbook
The native workbook object to test. 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
true
if a Workbook host item has been created for the current Workbook object; otherwise, false
.
Remarks
In a document-level customization, this method returns true
only if the Microsoft.Office.Interop.Excel.Workbook object on which you call this method is the underlying object of a Microsoft.Office.Tools.Excel.Workbook 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. 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 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.