Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XL97:Suppressing Print Preview

197 views
Skip to first unread message

Nick Osdale-Popa

unread,
Mar 21, 2001, 1:58:33 PM3/21/01
to
I am manually setting pagebreaks in a worksheet and I want to make sure that
the sheet prints to 1 page wide. I have to use the PrintPreview method to
retrieve the Zoom factor so that the pagebreaks will work. I use the
following code to accomplish this. (if there is a better way please let me
know!)

Even with ScreenUpdating set to False Excel still "flashes" the
PrintPreview. Is there another way of suppressing this?

Dim ZoomFactor as Integer
With Activesheet.PageSetup
.FitToPagesTall = False
.FitToPagesWide = 1
End With
'in order to calculate the Zoom %, a PrintPreview must initiated.
SendKeys "%C"
ActiveSheet.PrintPreview
'to get/set the Zoom %, initiate the Page Setup Dialog box.
SendKeys "P%A~"
Application.Dialogs(xlDialogPageSetup).Show
ZoomFactor = ActiveSheet.PageSetup.Zoom
ActiveSheet.PageSetup.Zoom = ZoomFactor


Jim Rech

unread,
Mar 21, 2001, 3:10:22 PM3/21/01
to
Good work figuring out how to get the zoom. I've added some additions that
should suppress the screen:

Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Sub SetPageZoom()
Dim ZoomFactor As Integer
Dim hWnd As Long

hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd

With ActiveSheet.PageSetup


.FitToPagesTall = False
.FitToPagesWide = 1

.Zoom = False


End With
'in order to calculate the Zoom %, a PrintPreview must initiated.
SendKeys "%C"
ActiveSheet.PrintPreview
'to get/set the Zoom %, initiate the Page Setup Dialog box.
SendKeys "P%A~"
Application.Dialogs(xlDialogPageSetup).Show
ZoomFactor = ActiveSheet.PageSetup.Zoom
ActiveSheet.PageSetup.Zoom = ZoomFactor

LockWindowUpdate 0
End Sub


--
Jim Rech
Excel MVP

0 new messages