Locking Zoom - Continuously Running Macro

JazzzyJo

Board Regular
Joined
Jul 12, 2011
Messages
60
Hello all

I found the following macro online which I put under Workbook_Open.
It works and does what I need it to do which is to (virtually) "lock" the zoom to 70% in the workbook.

But it means there will always be a macro running in the background.
WIll it affect the workbook in some way? Slow it down or other effect I can't think of?

If not, is there another way to achieve this?

Thank you all

Sub LockZoomInExcel()
Do
If ActiveWindow.Zoom <> 70 Then
ActiveWindow.Zoom = 70
End If
DoEvents
Loop While True
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Once it finishes running, it's done unless something calls it again. The only thing that calls a workbook open event is opening the wb (unless you have other code that calls the wb open event).
 
Upvote 0
I
Once it finishes running, it's done unless something calls it again. The only thing that calls a workbook open event is opening the wb (unless you have other code that calls the wb open event).
I posted too fast. It does not work if I put it in Workbook_Open. It makes all the other macro not work for some reason.
So I moved it out of Workbook_Open and I call it in another macro that is use early in the workbook.

So same question.

Thank you
 
Upvote 0
So why not this line inserted at the start of the other macro
VBA Code:
ActiveWindow.Zoom = 70
 
Upvote 0
Why do you want to lock the zoom ? Is that to prevent users from changing it ?
Running a continious loop in the background does and will slow down excel and, in some excel editions, it interferes with the Drag N Drop functionality and may even cause excel to crash.

A less heavy alternative that comes to mind would probably be to temporarly disable (or hide) the zoom related buttons located on the ribbon as well as the zoom slider control located on the status bar.
 
Upvote 0
Shoot, I missed the Do Loop While True and interpreted it as Do Events, which is something else altogether. As mentioned, you don't want to run a continuous loop like that.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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