Workbook Class (2007 System)

Represents a workbook in Visual Studio Tools for Office projects for Microsoft Office Excel. 

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

Syntax

'Declaration
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class Workbook _
    Inherits EntryPointBindableComponentBase _
    Implements IActivatable, IServiceProviderCallback, IOfficeHostItemEntryPoint, IEntryPoint,  _
    ISupportInitializeControl, ISupportInitialize
'Usage
Dim instance As Workbook
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class Workbook : EntryPointBindableComponentBase, IActivatable, 
    IServiceProviderCallback, IOfficeHostItemEntryPoint, IEntryPoint, ISupportInitializeControl, ISupportInitialize
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class Workbook : public EntryPointBindableComponentBase, 
    IActivatable, IServiceProviderCallback, IOfficeHostItemEntryPoint, IEntryPoint, ISupportInitializeControl, 
    ISupportInitialize
public class Workbook extends EntryPointBindableComponentBase implements IActivatable, IServiceProviderCallback, IOfficeHostItemEntryPoint, IEntryPoint, ISupportInitializeControl, ISupportInitialize

Remarks

The Microsoft.Office.Tools.Excel.Workbook class is the base class for workbook host items in Visual Studio Tools for Office projects. The Microsoft.Office.Tools.Excel.Workbook class provides the same members as the Workbook class in the Excel primary interop assembly, but it adds the following features:

  • VstoSmartTags property. Use this property to add smart tags to a workbook.

  • InnerObject property. Use this property to get the underlying Workbook object for a Microsoft.Office.Tools.Excel.Workbook host item.

  • RemoveCustomization method. Use this method to remove the Visual Studio Tools for Office customization assembly from the workbook in a document-level customization.

  • CreateRibbonObjects method. Override this method if you added multiple custom Ribbons to your project by using the Ribbon (Visual Designer) item template, and you want to specify which Ribbons to display at run time.

  • GetAutomationObject method. Override this method to expose a class in your project to VBA code in the workbook.

For more information about the role the Microsoft.Office.Tools.Excel.Workbook class plays in Visual Studio Tools for Office projects, see Host Items and Host Controls Overview and Workbook Host Item.

Creating Workbook Host Items

In application-level projects created by using Visual Studio 2008 Service Pack 1 (SP1), you can create Microsoft.Office.Tools.Excel.Workbook objects programmatically by using the GetVstoObject method of any Workbook object. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.

In document-level projects, you cannot create a Microsoft.Office.Tools.Excel.Workbook object programmatically. Instead, use the ThisWorkbook class to programmatically access the workbook in your project. Visual Studio generates this class in your project at design time. The ThisWorkbook class derives from the Microsoft.Office.Tools.Excel.Workbook class, and it is instantiated automatically by the Visual Studio Tools for Office runtime when the end user opens the document. For more information, see Programming Document-Level Customizations.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Tools.Office.RemoteComponent
    Microsoft.VisualStudio.Tools.Office.EntryPointComponentBase
      Microsoft.VisualStudio.Tools.Office.EntryPointBindableComponentBase
        Microsoft.Office.Tools.Excel.Workbook

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Workbook Members

Microsoft.Office.Tools.Excel Namespace

Other Resources

Host Items and Host Controls Overview

Workbook Host Item