I am trying to make a macro that adjusts the row heigt and column width within the printarea so that they fit a certain number of pages before printing to pdf. The purpose of this macro is to generate the "same" pdf file no matter what computer (with differet resolution, print settings and so on) when printing.
The printing to pdf works well for me, but the fitting of the columns and rows not so much
I have realised that the following section adjusts the column width and that the input needed is in excel units:
In my current setup the column width needs to be 2.14 (excel units). So far so good, now to determine what the width should be on any computer.
I get the page width in points:
Subtract the margins and divide by 32 (beeing the number columns that I would like to fit on one page):
Now I have the column width needed in points so I transform that to excel units by a factor:
And apply the found width to the columns of interest.
What I get is a cWid of 2.0601 (excel units) for my setup instead of the needed 2.14. Same procedure is used for the rows (subtracting the header, footer, top and bottom margins from the page height of 11.692 inches) yielding a cHei of 1.841664 instead of 2.14 which is also needed here (50 rows on one page)
Margins are set to normal in the macro before any of the editing of the column and row width and height.
Any clue what I am doing wrong? Or if there is a better way to reach the same goal (generating a pdf that looks exatcly the same when printing from different computers)?
Regards Emil
Bookmarks