DefaultDurationUnits property

Microsoft Visio Developer Reference

DefaultDurationUnits property

   Example   

Determines the default unit of measure for quantities that represent durations.

Version added

2002

Syntax

unitsCode = object.DefaultDurationUnits
object.DefaultDurationUnits = unitsNameOrCode

unitsCode

Variant. The default duration unit of measure.

object

Required. An expression that returns an Application object.

unitsNameOrCode

Optional Variant. The new default duration unit of measure.

Remarks

The DefaultDurationUnits property corresponds to the value shown in the Duration box on the Regional tab in the Options dialog box (on the Tools menu, click Options).

The return value unitsCode contains one of the values of VisUnitCodes, which are declared in the Visio type library.

You can specify unitsNameOrCode as an integer (a member of VisUnitCodes) or a string value such as "minutes". If the string is invalid or the unit code is inappropriate (non-duration), an error is generated.

For a complete list of valid unit strings along with corresponding Automation constants (integer values), see About units of measure.

Cell formulas that contain a specific unit of measure are displayed in those units regardless of the default duration units setting. Many cell formulas, however, use implicit unit syntax and are displayed in default units.

A program can create a cell whose formula displays in default units by setting the cell's Formula property to a string in implicit unit syntax. For example, if a formula specifying duration is "=10[em,E]" , the result displays as "0.0069 ed" if the DefaultDurationUnits property is visElapsedDay, and "600.0000 es" if the DefaultDurationUnits property is visElapsedSec.

Alternatively, a program can set the cell's result to default duration units using the following statement:

cellObj.Result(visDurationUnits) = 60 

In this case, the result is 60 minutes if the DefaultDurationUnits property is visElapsedMin and 60 seconds if the DefaultDurationUnits property is visElapsedSec.

For details about implicit units of measure, see About units of measure.