View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Newbie Questions

An object is an entity such as a workbook, worksheet or range (Like a
noun). In the object browser, objects will usually be refered to as a
class.

an object can have properties (attributes) (properties can themselves be
objects)
Workbook
Name
Worksheets

Worksheet
Name
UsedRange
parent <== also an object (workbook)
Range <== also an object


Range
address
Interior.colorIndex
Font.colorIndex

visually, a range has a background color and a font color. However, in the
object model, the range has an interior (object) which can have a color or
colorindex and the font can have a name, size, color, colorindex. The
reason these are objects is because other types of objects can also have
interiors and fonts. So this makes them reusable.



If the property is not read only, you can assign it a value

Activeworkbook.Worksheets("Sheet1"). Range("A1").Interior.ColorIndex = 3
' Makes the cell A1 red.


A method is like a verb, it performs an action

ActiveWorkbook.Worksheets.Add

adds a new worksheet the active workbook

A class is generally used to refer to a developer defined object that will
usually also have properties and methods created by the developer using a
class module. However, as was stated at the start, a more general view is
that class and object are interchangable.

I am sure others will have useful thoughts as well. Note that none of the
listings used are exhaustive, but are illustrative.

--
Regards,
Tom Ogilvy


"Steve P" <Steve wrote in message
...
Hi guys,

I am totally new to vba programming and wanted to know if anyone could
explain the relationship between classes, objects, methods, and
properties.
I bought a good book on vba for excel, but am still a little confused.

Can anyone clarify?