Object variables are assigned in a slightly different way from other variables. For example, if a variable is shared between procedures, you declare the variable as a script-level variable. In this procedure, the ItemChanged variable is declared as a script-level variable. ItemChanged is set to True whenever a standard property is changed in an item.
Dim ItemChanged ' Script-level variable.
Sub ltem_PropertyChange(ByVal Name) ItemChanged = True
An object variable is a variable that is used to refer to an object. As shown in the following example, you don't need to declare the variable. Instead, you use the Set statement to assign an object to a variable. The first line of code in the following example assigns the object variable to the newly created item. Once you've set an object, you can then use the object's methods and properties to control the object. This example creates a new mail item, and then displays the item.
Set objltem = Application.Createltem(O) objltem. Display
Was this article helpful?