Author Topic: PageHeight returning inches for some reason  (Read 73 times)

0 Members and 1 Guest are viewing this topic.

morelup

  • Newbie
  • *
  • Posts: 9
PageHeight returning inches for some reason
« on: January 15, 2020, 08:26:57 PM »
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?

morelup

  • Newbie
  • *
  • Posts: 9
Re: PageHeight returning inches for some reason
« Reply #1 on: January 15, 2020, 08:30:33 PM »
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.

ImAPictureFormat

  • Jr. Member
  • **
  • Posts: 16
Re: PageHeight returning inches for some reason
« Reply #2 on: January 16, 2020, 10:58:38 AM »
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:

Code: [Select]
_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.