DefaultPageUnits property

Microsoft Visio Developer Reference

DefaultPageUnits property

   Example   

Determines the default unit of measure for quantities that represent position or distance.

Version added

2002

Syntax

unitsCode = object.DefaultPageUnits
object.DefaultPageUnits = unitsNameOrCode

unitsCode

Variant. The default page units.

object

Required. An expression that returns an Application object.

unitsNameOrCode

Optional Variant. New default page units.

Remarks

The DefaultPageUnits property corresponds to the value shown in the Page 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 "inches". If the string is invalid or the unit code is inappropriate (non-distance), 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 page units setting. Many cell formulas, however, use implicit unit syntax and are displayed in default units.

A program can create a cell whose formula is displayed in default units by setting the cell's Formula property to a string in implicit unit syntax. For example, the formula "=5[in,P]" displays as "5 in." if the DefaultPageUnits property is visInches, and "12.7 cm" if the DefaultPageUnits property is visCentimeters.

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

cellObj.Result(visPageUnits) = 5 

In this case, the result is 5 inches if the DefaultPageUnits property is visInches and 5 centimeters if the DefaultPageUnits property is visCentimeters.

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

The value of the DefaultPageUnits property determines how blank drawings are created. If the value is a metric unit of measure, then the blank drawing is created using metric units. If the value is an imperial unit of measure, the blank drawing is created using imperial units. Default page units do not apply to new drawings created from a template.

Other operations can change the value of the DefaultPageUnits property. If you change the scale or measurement units for a particular page using the Page Setup dialog box, Visio changes the default page units for all drawings in the application.

Note Visio maintains internal default unit settings for position and distance in the drawing (visDrawingUnits) as opposed to those on the page. Default drawing units cannot be set explicitly, or queried directly. However, they can be inferred from the ratio of cellObj.Result(visDrawingUnits) to cellObj.Result(specificUnit) where specificUnit identifies a known unit of length such as visInches.

You can also use implicit syntax to create formulas that display in default drawing units, for example, "=5[i,D]".

If you set the value of DefaultPageUnits when the current settings for default page units and default drawing units are the same, both settings are changed.