How can you make a form maximized in vba. the other vb languages give you a property but vba doesn't, does anyone have code for this. cheers.
Printable View
How can you make a form maximized in vba. the other vb languages give you a property but vba doesn't, does anyone have code for this. cheers.
WindowState property is the one you're looking for.
Value 0 - Normal
Value 1 - Minimized
Value 2 - Maximized
VBA question moved to Office Development
I am using VBA not VB6 can you still help plz. In VBA it dont have a Windows State Property
you can use API:
VB Code:
Private Declare Function ShowWindow Lib "user32" ( _ ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Const SW_MAXIMIZE = 3 Private Sub UserForm_Click() ShowWindow FindWindow(vbNullString, Me.Caption), SW_MAXIMIZE End Sub
Unfortunately that goes over the taskbar as well :ehh: (well for me anyway)
That's because in VBA Userforms are more like dialog boxes than actual windows. If you want to maximize it, you need to set the width and height properties to the size of the screen, or use the API.
zaza
I tried the code bush mobile but it didn't maximize the form. i want it so you cannot move the form around with a maximized screen
Showwindow will not work as the controlbox doesnot have the maximize option. Basically its disabled. You need to use the SetWindowPos API and adjust the forms properties so its fullscreen. The otehr part is using APIs to get the screen size as there is no screen object in vba like there is in vb6.
What about DoCmd.Maximize in the form Open event?
No can DoCmd in Excel. If hes using Access then yes. ;)
Ah. Didn't know that, never used Excel forms.