Hello,
Here's a solution that sizes the userform and the controls on the userform. Also, it uses an API call to determine the users screen resolution and sizes both accordingly.
Here's the code:
'First the 32-bit API declaration. Placed above the code that follows...
'''''''''''''''''''''''
Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
'now the code. Change references to "ufMain" to the name of your userform. Also, LB1 below is a listbox on my userform. Remove this if you don't need it.
'''''''''''''''''''''''''
' Show your userform
ufMain.Show
' get size of users screen
Dim vidWidth As Variant
Dim vidHeight As Variant
vidWidth = GetSystemMetrics(SM_CXSCREEN)
vidHeight = GetSystemMetrics(SM_CYSCREEN)
If vidWidth = 800 Then
ufMain.Height = Application.Height - 107
GoTo byeBye
End If
If vidWidth = 1024 Then GoTo 1024
MsgBox "Please adjust your screen resolution to 800 x 600 or 1024 x 768"
Exit Sub
1024:
Dim ctrl As Control
If ufMain.Height = Application.Height - 107 Then GoTo byeBye
ufMain.Width = ufMain.Width * 1.28
ufMain.Height = Application.Height - 107
With ufMain.LB1
.Font.Size = 9
.Height = 168
End With
For Each ctrl In ufMain.Controls
ctrl.Height = ctrl.Height * 1.28
ctrl.Top = ctrl.Top * 1.28
ctrl.Width = ctrl.Width * 1.28
ctrl.Left = ctrl.Left * 1.28
Next ctrl
' That's it! Hope it works.
' Let's us know how you fare. Email me
' at
darinr@cox.net with questions.