WindowState Application Property in VBA is used to returns or sets the state of the application window based on XlWindowState. Please find below more information about WindowState.

Excel VBA WindowState Application Property

VBA WindowState Application Property – Syntax

Here syntax for WindowState Property of application object in VBA.

Application. WindowState

Where WindowState as XlWindowState: It specifies the state of the window. Please find the XlWindowState enumeration values at the end of the chapter. In the above syntax an Application represents object and WindowState is the Property of an Application object.

VBA WindowState Application Property: xlMaximized

Please find the below example for WindowState Property of application object in excel VBA. The below example maximizes the application window.

Sub Window_xlMaximized()
Application.WindowState = xlMaximized
End Sub

VBA WindowState Application Property: xlMinimized

Please find the below example for WindowState Property of application object in excel VBA. The below example minimizes the application window.

Sub Window_xlMinimized()
Application.WindowState = xlMinimized
End Sub

VBA WindowState Application Property: xlNormal

Please find the below example for WindowState Property of application object in excel VBA. The below example sets the application window to normal state.

Sub Window_xlNormal()
Application.WindowState = xlNormal
End Sub

VBA WindowState Application Property – Instructions

Please follow the below steps to execute the VBA code to save the excel file.
Step 1: Open any existing Excel Application.
Step 2: Press Alt+F11 – This will open the VBA Editor.
Step 3: Insert a code module from then insert menu.
Step 4: Copy the above code and paste in the code module which have inserted in the above step.
Step 5: Now press F5 to execute the code.

VBA WindowState Application Property – XlWindowState Enumeration

Please find the below XlWindowState enumeration values and their description in the table. Where XlWindowState represents the state of the window in Excel.

Window StateExcel NameValue
MaximizedxlMaximized-4137
MinimizedxlMinimized-4140
NormalxlNormal-4143

Hey! Join Our Community

Get Quick Responses & Experts' Answers in Minutes!
Get Notified - When Answered Your Question!