0% found this document useful (0 votes)
30 views

Lecture 16

This document provides an overview of key concepts about objects in Excel VBA. It discusses that objects have unique properties and methods, objects can be manipulated without selecting them first, it is important to understand collections which objects are referenced through, properties can return references to other objects, and the same object can be referred to in multiple ways. The document aims to explain essential object-oriented programming concepts for Excel VBA.

Uploaded by

Abby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Lecture 16

This document provides an overview of key concepts about objects in Excel VBA. It discusses that objects have unique properties and methods, objects can be manipulated without selecting them first, it is important to understand collections which objects are referenced through, properties can return references to other objects, and the same object can be referred to in multiple ways. The document aims to explain essential object-oriented programming concepts for Excel VBA.

Uploaded by

Abby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2/17/2012

Lecture 16: Excel VBA

Introduction to Computer
Programming for Engineering

Lecture 16: Excel VBA

ESSENTIAL CONCEPTS
ABOUT OBJECTS

1
2/17/2012

Objects have unique properties and


methods

 Each object has its own set of properties


and methods.

 Some objects, however, share some


properties (for example, Name) and some
methods (such as Delete).

You can manipulate objects


without selecting them.

 This idea may be contrary to how you


normally think about manipulating objects
in Excel.

 The fact is that it’s usually more efficient


to perform actions on objects without
selecting them first.

2
2/17/2012

It’s important that you understand the


concept of collections.
 Most of the time, you refer to an object indirectly
by referring to the collection that it’s in.

 For example, to access a Workbook object named


Myfile, reference the Workbooks collection as
follows:

◦ Workbooks(“Myfile.xlsx”)

 This reference returns an object, which is the


workbook with which you’re concerned.

Properties can return a


reference to another object.

 For example, in the following statement,


the Font property returns a Font object
contained in a Range object. Bold is a
property of the Font object, not the
Range object.

◦ Range(“A1”).Font.Bold = True

3
2/17/2012

You can refer to the same


object in many different ways.
 For example, you can refer to the sheet in
any of the following ways:

◦ Workbooks(“Sales.xlsx”).Worksheets(“Summary
”)
◦ Workbooks(1).Worksheets(1)
◦ Workbooks(1).Sheets(1)
◦ Application.ActiveWorkbook.ActiveSheet
◦ ActiveWorkbook.ActiveSheet
◦ ActiveSheet

You might also like