MrExcel Publishing
Your One Stop for Excel Tips & Solutions


Posted by Cory on June 23, 2001 9:16 AM

How do you get a form to maximize upon startup of your application?

Posted by Dax on June 23, 2001 10:17 AM

If you go into the VB Editor (Alt+F11), click View, Project Explorer and then double click the ThisWorkbook icon. Add a bit of code which will open the userform e.g.

Private Sub Workbook_Open()
End Sub

Then go into the code module of the userform and enter this code. This code uses an API call to determine the screen size. You could omit this part if you know that your users and you all use the same screen size.

Private Const SM_CYSCREEN As Long = 1
Private Const SM_CXSCREEN As Long = 0

Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long

Private Sub UserForm_Activate()
Dim lScreenHeight As Long, lScreenWidth As Long

lScreenHeight = GetSystemMetrics(SM_CYSCREEN)
lScreenWidth = GetSystemMetrics(SM_CXSCREEN)

Me.Left = 0
Me.Top = 0
Me.Height = lScreenHeight
Me.Width = lScreenWidth
End Sub

Any help?


Posted by Cory on June 25, 2001 8:22 AM

Thanks, Dax! Worked great!