Chapter 6: The Application Object

 < Day Day Up > 



Overview

Visual Basic for Applications (VBA) uses objects to control Microsoft Excel. Whether you are working with the Excel application (Application object), workbooks (Workbook object), or individual cells (Cell object), you do everything by manipulating an object. All of the objects either contain other objects or are part of a larger object. For example, the Workbook object contains Worksheets objects, which in turn contain Cell objects.

When working with an object, either a property is being set or read, or the object is told to perform an action, called a method. If you wanted to select a worksheet named Sheet2 in the active workbook, you would use the Select method of the Worksheet object, Worksheets(“Sheet2”).Select.

The object model (shown in Figure 6-1) is used to describe how each object within Excel relates to other objects. When you view the object model, you can see how one object contains other objects, which contain other objects, which can contain even more objects. An object might even contain multiple objects of the same type. For example, a workbook can contain multiple worksheets.

click to expand
Figure 6-1: The Microsoft Office 2003 Excel Object Model is the repository of all knowledge in Excel.

An object that contains multiple objects of the same type is a collection, and each object within the collection is a member of the collection. To refer to a particular member of a collection, you can use either its index number or its name. In the preceding example, we used the Worksheets collection and referred to the particular worksheet named Sheet2.



 < Day Day Up > 



Microsoft Excel 2003 Programming Inside Out
Microsoft Office Excel 2003 Programming Inside Out (Inside Out (Microsoft))
ISBN: 0735619859
EAN: 2147483647
Year: 2006
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net