Visio Guy

Visio Discussions => Programming & Code => Topic started by: morelup on January 16, 2020, 01:26:57 AM

Title: PageHeight returning inches for some reason
Post by: morelup on January 16, 2020, 01:26:57 AM
So I have an addin that is doing some logic based off of PageHeight.  This works fine on my laptop that i've developed on, and everyone i've deployed this addin to has not had this issue.  On my newly built PC though when I do the below logic:

_pageHeight = Convert.ToDouble(_page.PageSheet.Cells["PageHeight"].Formula.Replace(" mm.", ""));

I'm getting an error because .Formula is returning the value in inches.  The strange thing is, i'm opening up identical files on both my working laptop and non-working desktop, and when inspecting the page on the desktop it shows as "PageHeight = 210 mm"

Any ideas what I am doing wrong?
Title: Re: PageHeight returning inches for some reason
Post by: morelup on January 16, 2020, 01:30:33 AM
Ok, strangest thing, now this desktop works fine, but I have to change the tab I'm looking at when the file opens up (note i can go back to that tab after changing) and it works fine.
Title: Re: PageHeight returning inches for some reason
Post by: ImAPictureFormat on January 16, 2020, 03:58:38 PM
Most of my experience is with VBA, but I believe you could do something like this to always get the result in millimeters across your devices:


_pageHeight = Convert.ToDouble(_page.PageSheet.Cells["PageHeight"].Result(visMillimeters).Replace(" mm.", ""));


The constant visMillimeters I'm getting from the documentation here: https://docs.microsoft.com/en-us/office/vba/api/visio.visunitcodes

Hope this helps.