Workbook Workbook Workbook Interface
Represents a Microsoft Excel workbook.
public interface class Workbook : Microsoft::Office::Interop::Excel::_Workbook, Microsoft::Office::Interop::Excel::WorkbookEvents_Event
[System.Runtime.InteropServices.Guid("000208DA-0000-0000-C000-000000000046")] public interface Workbook : Microsoft.Office.Interop.Excel._Workbook, Microsoft.Office.Interop.Excel.WorkbookEvents_Event
Public Interface Workbook Implements _Workbook, WorkbookEvents_Event
This is a .NET interface derived from a COM coclass that is required by managed code for interoperability with the corresponding COM object. Use this derived interface to access all method, property, and event members of the COM object. However, if a method or event you want to use shares the same name under the same COM object, cast to the corresponding primary interface to call the method, and cast to the latest events interface to connect to the event. Refer to this topic for information about the COM object. For information about the method and property members of the COM object, see _Workbook.
The following properties for returning a Workbook object are described in this section:
index is the workbook name or index number, to return a single Workbook object.
The index number denotes the order in which the workbooks were opened or created. Workbooks(1) is the first workbook created, and Workbooks(Workbooks.Count) is the last one created. Activating a workbook doesn’t change its index number. All workbooks are included in the index count, even if they’re hidden.
The Name property returns the workbook name. You cannot set the name by using this property; if you need to change the name, use the SaveAs(Object, Object, Object, Object, Object, Object, XlSaveAsAccessMode, Object, Object, Object, Object, Object) method to save the workbook under a different name.
The ActiveWorkbook property returns the workbook that’s currently active.
The ThisWorkbook property returns the workbook where the Visual Basic code is running. In most cases, this is the same as the active workbook. However, if the Visual Basic code is part of an add-in, the ThisWorkbook property won’t return the active workbook. In this case, the active workbook is the workbook calling the add-in, so the ThisWorkbook property returns the add-in workbook.
If you’ll be creating an add-in from your Visual Basic code, you should use the ThisWorkbook property to qualify any statement that must be run on the workbook you compile into the add-in.