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.
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