Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine PageSetup Zoom Value When Fit To is Selected and related issues

Status
Not open for further replies.

Gav42

Technical User
Sep 19, 2013
4
GB
I am trying to determine (xl 2010) what the PageSetup zoom value is when FitToPagesWide is set. I found this 2006 post that describes the problem and a solution that still works. The following code works, thanks to Ron Page but surely there is a better way than using an Excel4 macro?

Code:
with sh.pagesetup
        .PaperSize = xlPaperA4
        .Orientation = xlPortrait
        .FitToPagesWide = 1
        .FitToPagesTall = False
        'Application.PrintCommunication = False
        [COLOR=#EF2929]Application.ExecuteExcel4Macro "PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})"[/color][COLOR=#CC0000][/color]       
       ' MsgBox "Zoom factor is " & ActiveSheet.PageSetup.Zoom
        Select Case .Zoom  
        Case Is > 100
            .Zoom = 100
        Case Is < 69
            .Orientation = xlLandscape
            .FitToPagesWide = 1
        End Select
[URL unfurl="true"]http://www.ozgrid.com/forum/showthread.php?t=49644[/url]

There is a second problem that is what prompted me to write this code. FitToPagesWide seems to zoom some pages unnecessarily. It can return a zoom of 50-60% but in fact if I do the job by hand I find that 71% is fine. So if there is a workaround for that issue I would love to hear (I have reset the last cell and defined a print range but niether helps).

Finally is there a way of telling how many pages wide the print will be? I am thinking I could create my own (inefficient) function to loop though different zoom values to do a fit to 1 wide.

Thanks for your help.

Gav
 
You can play with VPageBreaks collection.
Alternative to .FitToPagesWide=1:
sh.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top