Microsoft Office Tutorials and References
In Depth Information
9.4 Object Model Syntax
9.4 Object Model Syntax
It is time that we formally discuss the basic syntax that is used when programming with an object
The general syntax for referring to an object's properties and methods is very simple. If objVar is
an object variable that refers to a particular object and AProperty is a property of this object,
then we can access this property (for reading or for changing) using the syntax:
objVar.AProperty( any required parameters )
For instance, the following code sets the font name property of the first row in the active
' Declare object variable
Dim rng As Range
' Set rng to refer to first row
Set rng = ActiveSheet.Rows(1)
' Set font name
rng.Font.Name = "Arial"
Note that the last line of code actually invokes two properties; the Font property of rng returns a
Font object, whose Name property is set to Arial.
If AMethod is a method for this object, then we can invoke that method with the syntax:
Search JabSto ::

Custom Search