Visio Guy

Visio Discussions => Programming & Code => Topic started by: robert.cowham on April 30, 2012, 02:52:37 PM

Title: How to find Page "Measurement Units" in code?
Post by: robert.cowham on April 30, 2012, 02:52:37 PM
I am not sure what is the best way to find this out - the user can set a value (in Visio 2010) by right clicking Page tab > Page Setup > Page Properties > MEasurement Units

Valid values range from Inches to Kilometers (and the oddities such as Ciceros etc)

In the shape sheet window for the page, there are cells such as:

DrawingSizeType, DrawingScaleType

But they don't change if I modify Measurement Units (from say Meters to Feet)

Suggestions for best way to find out what the user has done?
Title: Re: How to find Page "Measurement Units" in code?
Post by: saveenr on April 30, 2012, 04:21:47 PM
I tried doing this in Visio 2010 just now.

When brought up the page shapesheet window and the Page Setup dialog. Any changes to Measurement Units in the Page Setup dialog seem to be mirrored in the PageScale, and DrawingScale cells.

For example when I set Measurement Units to "Feet" I saw that the PageScale and DrawingScale were both set to "1 ft" immediately.
Title: Re: How to find Page "Measurement Units" in code?
Post by: robert.cowham on April 30, 2012, 07:47:04 PM
After posting, I realized a variation on a similar idea - hope this sort of thing works:

      Dim units As Short = m_VisioApp.ActivePage.PageSheet.Cells("DrawingScale").Units
        If units = Visio.VisUnitCodes.visMillimeters Or units = Visio.VisUnitCodes.visCentimeters Or _
            units = Visio.VisUnitCodes.visMeters Or units = Visio.VisUnitCodes.visKilometers Then
            ReadPageUnits = "mm"
        Else
            ReadPageUnits = "in"
        End If

I want to use "mm" for metric and "inches" for Imperial. This ignores a whole load of esoteric units such as Ciceros...