Page Setup and Zoom Property

CT Witter

MrExcel MVP
Joined
Jul 7, 2002
Messages
1,212
I was curious if in VBA is there a way to switch in the page setup from Fit to X Page by X Page to the Scaling %.

I have set all my pages to fit 1 x 1 and would now like to know the scaling % (Zoom) of the sheets.


Thanks,
CT
 
Maybe I don't understand the issue, but is this what you want?

Option Explicit
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()
'Lock the window so zoom cannot change during evaluation
LockWindowUpdate FindWindowA("XLMAIN", Application.Caption)
With ActiveSheet.PageSetup
.FitToPagesTall = 1
.FitToPagesWide = 1
.Zoom = False
End With
'Activate PrintPreview to evaluate current Zoom
SendKeys "%C"
ActiveSheet.PrintPreview
'Activate PageSetUp to return current Zoom
SendKeys "P%A~"
Application.Dialogs(xlDialogPageSetup).Show
MsgBox ActiveSheet.PageSetup.Zoom
LockWindowUpdate 0
End Sub
Hey!
Great information!! Just lacking personal knowledge now! :/
OK, I am very new to VBA so any adjustments and I wont be able to see whats what.
I believe that this code is what I am searching for but doesn't work for me and I know I am to blame!
I need a code to lock my worksheet to 56% and thats final! I want it to revert back to 56% when re-opend as well as if anyone attempts to manually zoom with either the mouse roller+Ctrl.
I would appreciate efforts made and and helpful tips to understand VBA.
Thanks
Steve
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I used your code and it worked perfect. What I need to do is capture the Zoom to a variable so I can assign it so I can set page breaks and still have it FitToPagesWide = 1 and FitToPagesTall =False as if FitToPagesWide was not False because I have the correct Zoom. When I used Z = ActiveSheet.PageSetup.Zoom, I got "False". I could see 52 in the msgbox but could not capture it.

Help

Mozzz
 
Upvote 0

Forum statistics

Threads
1,215,537
Messages
6,125,389
Members
449,222
Latest member
taner zz

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