'1、模块里先建立一个API:
Public Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
'2、在窗体下输入代码:
Private Sub CommandButton1_Click()
Application.Visible = False '将Excel文件隐藏
Dim x As Long, y As Long
x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)
'MsgBox "您的屏幕分辨率为:" & x & "*" & y
UserForm1.Width = x
UserForm1.Height = y
UserForm1.Top = 1
UserForm1.Left = 1
End Sub