Event triggered with ActiveWindow zoom event (hold

2020-04-17 07:41发布

I am building a dashboard and need to have zoom level set to 100%. So whenever User tries to Zoom using mouse wheel button or Zoom level option, I need to catch that event and return Zoom to 100%. I have searched all over internet for answer and found that there is no such thing as OnZoom event.

  • There is an option to check zoom level every few milliseconds and restore it to 100%, but i can't accept this cause of rounding circle appearing on mouse arrow constantly, which is distracting.
  • Hiding Zoom control is also not an option since user can still zoom with CTRL+MouseWheel.
  • Using Class modules also work only on manual selecting zoom level from menu View > Zoom solution

All answers I found were dated more than 5 years ago, so maybe in the meantime someone found a solution or this feature is added in newer versions of Excel?

Any lead will be much appreciated!

1条回答
等我变得足够好
2楼-- · 2020-04-17 07:56

Found a solution while playing with ActiveX controls, so for everyone who stumbled on this please find answer below.

First, insert ActiveX control named InkPicture control.

Resize control across whole Worksheet visible area.

In worksheet module, paste this code.

Private Sub InkPicture1_Resize(Left As Long, Top As Long, Right As Long, Bottom As Long)
ActiveWindow.Zoom = 100
End Sub

For some reason (hope someone can explain why?), when zooming occures, it triggers InkPicture_resize event! You can also set InkPicture visible property to false, and it will still works.

查看更多
登录 后发表回答