Hi Wes!
You Could try something this:
Place this code in Workbook Open:
Private Sub Workbook_Open()
Run "DisplayVideoInfo"
End Sub
Place this code in a module:
Declare Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
Declare Function GetSystemMetrics16 Lib "user" _
Alias "GetSystemMetrics" (ByVal nIndex As Integer) As Integer
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Sub DisplayVideoInfo()
Dim vidWidth As Integer, vidHeight As Integer
Dim Msg As String, Style As String
Dim Title As String, Response As String
If Left(Application.Version, 1) = 5 Then
vidWidth = GetSystemMetrics16(SM_CXSCREEN)
vidHeight = GetSystemMetrics16(SM_CYSCREEN)
Else
vidWidth = GetSystemMetrics32(SM_CXSCREEN)
vidHeight = GetSystemMetrics32(SM_CYSCREEN)
End If
If vidWidth = 1280 And vidHeight = 1024 Then
Sheets(1).Range("A1") = 600 'Set a sheet and a range where you can save this value
Sheets(1).Range("A2") = 800 'Set a sheet and a range where you can save this value
Else
If vidWidth = 1024 And vidHeight = 768 Then
Sheets(1).Range("A1") = 400 'Set a sheet and a range where you can save this value
Sheets(1).Range("A2") = 600 'Set a sheet and a range where you can save this value
Else
If vidWidth = 800 And vidHeight = 600 Then
Sheets(1).Range("A1") = 350 'Set a sheet and a range where you can save this value
Sheets(1).Range("A2") = 450 'Set a sheet and a range where you can save this value
End If
End If
End If
End Sub
And this code in UserForm Initialize:
Private Sub UserForm_Initialize()
With UserForm1
.Height = Sheets(1).Range("A1")
.Width = Sheets(1).Range("A2")
End With
End Sub
Create a sheet to store the values in, or select a "sheet.range"out of range for your work.
Change the values til you got the userform in the size you prefer.
Note: Cover all the screen resolutions you want to work with, otherwise your UserForm will be difficult to work with...
/Roger