Home/ Reference/ Enumerations

doc.Unit(cdrUnit)

Millimetres, inches, points, pixels and so on. The numbers can differ between versions; the reliable move is assign, read back, confirm. Don't hardcode them.

Signature

doc.Unit(cdrUnit)

Notes

Millimetres, inches, points, pixels and so on. The numbers can differ between versions; the reliable move is assign, read back, confirm. Don't hardcode them.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
# unit codes differ by version; assign, read back, then trust it
def set_unit(doc, code, name):
    doc.Unit = code
    if doc.Unit == code:
        print("Switched to ", name)
        return True
    print("code", code, "invalid, actually read back: ", doc.Unit)
    return False

set_unit(doc, 6, "mm")

About this section: Enumerations

Enumerations — VBA constants and their integer values.

Other entries in this section