Presentation is loading. Please wait.

Presentation is loading. Please wait.

Excel Object Model.

Similar presentations


Presentation on theme: "Excel Object Model."— Presentation transcript:

1 Excel Object Model

2 Object Oriented Programming
Property Method Event read write Each object in a Microsoft application has properties which you can view and/or change, methods which you can utilise within a procedure and associated events to which you can attach a sub-routine. Collection Object object

3 Object Oriented Programming
read/write Property Method execute procedure A sub-routine can :- - exchange values with any of an object’s properties - instruct an object to carry out any of its methods - provide code to run when any of an object’s events occur Event triggers

4 Workbook Object Workbook (object) Worksheets (property) Workbook_Open
(event) Close (method) You identify a collection of worksheets by using the enclosing workbook’s Worksheets property. Name (property) ActiveSheet (property) Collection Worksheet Worksheet Worksheet

5 Object Browser Window LIBRARY PROPERTIES METHODS EVENTS OBJECT CLASS
Use the view menu to locate the Object Browser Window and ensure that you have the appropriate libraries selected before searching for the object of interest.

6 Sub Current_Workbook() Dim wb As Workbook
Simple Sub-Routine Sub Current_Workbook() Dim wb As Workbook Set wb = Application.ActiveWorkbook Debug.Print wb.Name Set wb = Application.Workbooks(1) wb.Save End Sub OBJECT PROPERTY METHOD COLLECTION The sub-routine uses the variable wb to manipulate the active workbook.

7 References To Object Libraries
Visual Basic For Applications Microsoft Excel Object Library OLE Automation Microsoft Office Object Library Another Workbook

8 Simple Object Hierarchy
If in doubt about where the object you need lies in the hierarchy, start with the Application object and work down.

9 Create An Object Add Method new object collection

10 The object model is not perfectly consistent.
Always Remember … The distinction between a property and a method is not always clear-cut. The object model is not perfectly consistent. The sub-routine uses the variable wb to manipulate the active workbook.


Download ppt "Excel Object Model."

Similar presentations


Ads by Google