Hi, this is a code I use for a userform to do so... Perhaps u can use it...
In a class-mod
Option Explicit
' 32-bit API declaration
Private Declare Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
' 16-bit API declaration
Private Declare Function GetSystemMetrics16 Lib "user" _
Alias "GetSystemMetrics" (ByVal nIndex As Integer) As Integer
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Property Get GetCurrentWidth()
Dim vidWidth As Integer
If Left(Application.Version, 1) = 5 Then
' 16-bit Excel
vidWidth = GetSystemMetrics16(SM_CXSCREEN)
Else
' 32-bit Excel
vidWidth = GetSystemMetrics32(SM_CXSCREEN)
End If
GetCurrentWidth = vidWidth
End Property
Property Get GetCurrentHeight()
Dim vidHeight As Integer
If Left(Application.Version, 1) = 5 Then
' 16-bit Excel
vidHeight = GetSystemMetrics16(SM_CYSCREEN)
Else
' 32-bit Excel
vidHeight = GetSystemMetrics32(SM_CYSCREEN)
End If
GetCurrentHeight = vidHeight
End Property
In UserForm
Private Sub UserForm_Initialize()
Dim j As Integer
Dim Reso As New Klasse1
With Me
.Top = 0
.Left = 0
.Height = (Reso.GetCurrentHeight / 4) * 3
.Width = (Reso.GetCurrentWidth / 4) * 3
End With
With Me
For j = 0 To .Controls.Count - 1
With .Controls(j)
.Top = .Top * Reso.GetCurrentHeight / 600
.Height = .Height * Reso.GetCurrentHeight / 600
.Left = .Left * Reso.GetCurrentHeight / 600
.Width = .Width * Reso.GetCurrentHeight / 600
.Font.Size = Int(.Font.Size * Reso.GetCurrentHeight / 600)
End With
Next
End With
End sub
Good Luck.....
jajinder
Greets Jajinder