On a worksheet there's a command button to show UserForm1 and also minimize the Excel application's window.
Private Sub CommandButton1_Click()
Application.WindowState = xlMinimized
UserForm1.Show vbModeless
End Sub
There's code for UserForm1's "X" that unloads UserForm1 and should maximize the Excel window as the front window.
Private Sub cmdExit_Click()
If ExitAsk = vbYes Then
Unload Me
Application.WindowState = xlMaximized
End If
End Sub
Everything works but Excel stays minimized.
CodePudding user response:
There's code for UserForm1's "X" that unloads UserForm1 and should maximize the Excel window as the front window.
Is this what you are trying? This will maximize the userform the moment you press the X
on the userform.
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Application.WindowState = xlMaximized
End Sub
You can also use the UserForm_Terminate
event for this
Private Sub UserForm_Terminate()
Application.WindowState = xlMaximized
End Sub