Userform Zoom

Phil C

Board Regular
Joined
Apr 10, 2002
Messages
64
Is there any way of changing the zoom of a userform? I have code that changes the zoom of the spreadsheet depending on the resolution of the monitor could this be adapted to the userform code?


Dim wid As Integer
With ActiveWindow
wid = .UsableWidth
If wid > 1250 And wid <= 1400 Then
.Zoom = 120
ElseIf wid > 1100 And wid <= 1249 Then
.Zoom = 79
ElseIf wid > 980 And wid <= 1099 Then
.Zoom = 82
ElseIf wid > 880 And wid <= 979 Then
.Zoom = 74
ElseIf wid > 790 And wid <= 879 Then
.Zoom = 74
ElseIf wid > 760 And wid <= 789 Then
.Zoom = 65
ElseIf wid > 500 And wid <= 759 Then
.Zoom = 48
Else
.Zoom = 100
End If
End With
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Phil C

Board Regular
Joined
Apr 10, 2002
Messages
64
Juan
Yes I have tried it. The only results I can get is the items on the userform change size but not the actual form itself. I also had to change the .UsableWidth to .Width which prevented it from responding to monitor resolutions.

Thanks

Phil C
 

stevebausch

Well-known Member
Joined
May 11, 2002
Messages
810
Where are you putting the code?

It gets a bit tricky. Try putting the .Zoom assignment in Userform_Activate.

If you need to set .Zoom before Show ing the form, you probably need to Load it first.
 

Phil C

Board Regular
Joined
Apr 10, 2002
Messages
64
Originally I tried putting the code in two different places one in the userform_initialize and I also created a cmdbutton to call the code. Both changed the zoom of the objects on the userform but not the actual userform. It also does the same thing when I place the code with a userform_activate sub.

Thanks
 

stevebausch

Well-known Member
Joined
May 11, 2002
Messages
810
Well, yes, that's what .Zoom does.

If you are concerned about resizing the form, seems I maximize Excel, and
do something like:

With YourForm
.Zoom = CInt(Application.Width / 774 * 90)
.Width = Application.Width
.Height = Application.Height
End With

The 'magic number' 774 is roughly the number returned with 1024 by 768 resolution. '90' tends to set the .Zoom to 90%. So, in other resolutions, this code does a decent job of maximizing the window, and adjusting the zoom as needed. Not perfect, but it works ok.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,031
Messages
5,622,302
Members
415,891
Latest member
Oksana88

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
Top