Re: UserForm Size On Different Computers
- From: "Jim Cone" <jim.coneXXX@xxxxxxxxxx>
- Date: Tue, 5 Dec 2006 11:59:46 -0800
This is a modified code version that should require less tinkering.
It also should be easier to use as you only have to adjust the
BaseX and BaseY values before running the code.
(also change the userform name to the actual name)
There are some explanatory notes included in the code.
Note: The Declare Function GetSystemMetrics code line goes at the
very top of the module just below "Option Explicit"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
'---------------------------------
Public Function GetSR() As Variant
' x and y
GetSR = Array(GetSystemMetrics(0), GetSystemMetrics(1))
End Function
'---------------------------------
Sub ResizeForm_R1()
' Adjusts userform size to compensate for screen resolution changes.
' Jim Cone - San Francisco, USA - Dec 2006
Dim varSize As Variant
Dim RatioX As Single
Dim RatioY As Single
Dim ActualX As Long
Dim ActualY As Long
'Screen resolution in development environment.
'Adjust as necessary.
Const BaseX As Long = 800
Const BaseY As Long = 600
'Call function to get actual screen resolution
varSize = GetSR
ActualX = varSize(0)
ActualY = varSize(1)
'Determine ratio of actual screen resolution to
'the original or base resolution.
RatioX = ActualX / BaseX
RatioY = ActualY / BaseY
'Adjust userform magnification and size.
UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
UserForm1.Width = UserForm1.Width * RatioX
UserForm1.Height = UserForm1.Height * RatioY
UserForm1.Show
Unload UserForm1
Set UserForm1 = Nothing
End Sub
--------------
"Minitman" <exreply@xxxxxxxxx>
wrote in message
Hey Jim,
Thanks for the reply.
This is beyond my current level of understanding, but I think I can
find out the references to tell me what is going on. It will take me
a couple of days to muddle though it. It looks like what I need at
first glance.
I will give this a shot. Thanks.
-Minitman
On Mon, 4 Dec 2006 21:18:07 -0800, "Jim Cone"
<jim.coneXXX@xxxxxxxxxx>
wrote:
This will automatically adjust the form size depending on the
screen resolution. You should adjust the multiplication
factor and the resolution increments to suit.
.
- Follow-Ups:
- Re: UserForm Size On Different Computers
- From: Minitman
- Re: UserForm Size On Different Computers
- References:
- UserForm Size On Different Computers
- From: Minitman
- Re: UserForm Size On Different Computers
- From: Bob Phillips
- Re: UserForm Size On Different Computers
- From: Minitman
- Re: UserForm Size On Different Computers
- From: Jim Cone
- Re: UserForm Size On Different Computers
- From: Minitman
- UserForm Size On Different Computers
- Prev by Date: Re: help needed
- Next by Date: Re: How do i program a macro for print view
- Previous by thread: Re: UserForm Size On Different Computers
- Next by thread: Re: UserForm Size On Different Computers
- Index(es):
Relevant Pages
|