none
Determining units used in page layout via VBA RRS feed

  • Question

  • I'm using Visio as a GUI sketch tool for a control system and I am needing to update the VBA code for a new project. The old project we hard coded the units into a calculation subroutine. This new project required us to use a different unit (Centimeters) and I would like the code to be flexible enough to work with any future project and use whatever units the Page Layout is using.

    Is there a way to get this information programmatically?  I've tried looking at the ShapeSheet data for the page but it has "1 cm" for PageScale and DrawingScale.  My code currently uses visPoints for the calculation (See below):

      ' Get page dimensions
      X_PageDim = shpPage.Cells("PageWidth").Result(visPoints)
      Y_PageDim = shpPage.Cells("PageHeight").Result(visPoints)
      
      ' Get object position
      X_Pos = shp.CellsU("PinX").Result(visPoints)
      Y_Pos = shp.CellsU("PinY").Result(visPoints)

    In place of the visPoints I would like to place a variable that is filled with the units used by the Page Layout so that the calculations will be accurate.

    Any ideas?

    Friday, July 24, 2015 4:08 PM

Answers

  • Hi Raytrace,

    As far as I know, there is no such property or function we can get the units for the Visio document. However, as a workaround we can detect the unit of shape using via get the formula from the Cell object of shape.

    For example, here is the code print the formula for the width of a shape for your reference:

    Debug.Print ActiveDocument.Pages(1).Shapes(1).Cells("Width").Formula

    The document used 'Metric Units' and the output is like below:

    40 mm.

    And if you want Visio object model to support this property in the further version, you can submit the feedback from link below:
    Submit Feedback - Microsoft Support

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, July 28, 2015 2:45 AM
    Moderator

All replies

  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Visio, I'll move your question to the MSDN forum for Visio

    http://social.msdn.microsoft.com/Forums/en-US/home?forum=officegeneral&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    George Zhao
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.

    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.
    Monday, July 27, 2015 2:37 AM
  • Hi Raytrace,

    As far as I know, there is no such property or function we can get the units for the Visio document. However, as a workaround we can detect the unit of shape using via get the formula from the Cell object of shape.

    For example, here is the code print the formula for the width of a shape for your reference:

    Debug.Print ActiveDocument.Pages(1).Shapes(1).Cells("Width").Formula

    The document used 'Metric Units' and the output is like below:

    40 mm.

    And if you want Visio object model to support this property in the further version, you can submit the feedback from link below:
    Submit Feedback - Microsoft Support

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, July 28, 2015 2:45 AM
    Moderator