PDA

View Full Version : Returning Maximized WindowState with QueryClose_



Rlb53
04-07-2012, 03:46 PM
My "auto_open" macro is as follows:

Sub Auto_Open()

Application.EnableCancelKey = xlDisabled

Application.WindowState = xlNormal
Application.Left = 448
Application.Top = 253
Application.Width = 99
Application.Height = 28.5
EntranceForm.Show
End Sub


Upon activation of the userform macro as shown. It performs as intended and returns the Maximized WindowState Prior to the Quit Command.

Private Sub CommandButton2_Click()

Application.WindowState = xlMaximized

Application.DisplayFormulaBar = True

ActiveWindow.DisplayGridlines = True

ActiveWindow.DisplayHeadings = True

Application.DisplayFullScreen = False

Application.Quit

End Sub

However similar code called when the Close Button is activated on the userform does Not.

Private Sub UserForm_QueryClose _
(Cancel As Integer, CloseMode As Integer)

If CloseMode = vbFormControlMenu Then
'Cancel = True - Because I call for a different procedure, this has been turned off.

Unload Me

Application.WindowState = xlMaximized

Application.DisplayFormulaBar = True

ActiveWindow.DisplayGridlines = True

ActiveWindow.DisplayHeadings = True

Application.DisplayFullScreen = False

Application.Quit

End If

End Sub

Thoughts?