Page Setup, Zoom, and Screen Updating issue.

scapegoat9595

New Member
Joined
Jan 26, 2014
Messages
6
Hello everyone, I am looking for some insight as to whats going on with my code. I am learning a lot, but its my current issue that driving me bonkers. Im here to ask for some help.

I have created a user form for Excel "print" formatting and would like to give the user an option that would increase the amount of pages wide a sheet is set to until it reaches a Zoom (Page Scaling) of at or above 40%.

What i have below runs when the user selects that option, this takes place after each sheet is already set to 1 page wide by False tall.

Everything below works, but ONLY if screenupdating is set to true. I would love to have it turned off for all the obvious reasons, but I cannot find another way around this. Any insight or additional information would be greatly appreciated.

Code:
Sub AutoPagesWide()

Dim pZoom As Integer
Dim i As Integer

i = 1
    'the below returns the current Zoom percentage
    Application.ExecuteExcel4Macro "PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})"
    pZoom = ActiveSheet.PageSetup.Zoom
    
    Application.PrintCommunication = False
    Application.ScreenUpdating = True
    
    Do While (pZoom < 40)
            i = i + 1
        Application.PrintCommunication = False    
            With ActiveSheet.PageSetup
            .Zoom = False
            .FitToPagesWide = i
            .FitToPagesTall = False
            End With  
        Application.PrintCommunication = True
        'the below returns the current Zoom percentage again
        Application.ExecuteExcel4Macro "PAGE.SETUP(,,,,,,,,,,,,{#N/A,#N/A})"
        
        pZoom = ActiveSheet.PageSetup.Zoom

        Application.EnableEvents = True
    Loop
        
       Application.ScreenUpdating = False

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top