How to Fix Excel VBA WindowState xlNormal Bug After Excel Was Maximized
Question details
Users need to resolve an issue in Microsoft 365 where setting the window state to xlNormal via VBA fails to restore the window properly if Excel was previously closed while maximized.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running an automation script or VBA macro that adjusts the window state and resizes the active window by assigning Width and Height properties.
- Observed behavior
- Setting ActiveWindow.WindowState to xlNormal fails to restore the window, which causes any subsequent Width and Height dimension assignments in the VBA code to fail.
Verify your current Microsoft 365 build version and save a backup of your VBA project before testing any automation code modifications.
Use Application.WindowState as a Workaround
Set the application-level window state to xlNormal before attempting to adjust window dimensions to bypass the ActiveWindow bug.
In certain Microsoft 365 builds, a regression prevents the ActiveWindow object from restoring correctly if the application was last closed in a maximized state. By targeting the Application object directly, you can force the window state to reset, allowing height and width adjustments to process successfully.
Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.
Find the module and the specific macro where you are attempting to set the ActiveWindow.WindowState and window dimensions.
Insert or change the code to read 'Application.WindowState = xlNormal' before you assign the Width and Height properties.
Save the changes and run the macro to ensure the Excel window restores to a normal state and resizes correctly.

Submit a Microsoft 365 Support Request
Report the Office update regression to Microsoft to help developers investigate and issue a permanent patch.
Try WPS Office for Stable Spreadsheet and Macro Handling
Tired of unexpected regressions and VBA bugs after Office updates? WPS Office provides a stable, lightweight, and highly compatible alternative for your spreadsheet needs. It handles standard Excel files flawlessly and offers a familiar interface, making migration effortless.
- 1. Download the Software: Visit the official WPS Office website and click the free download button.
- 2. Install WPS Office: Run the setup file and follow the on-screen instructions to install the suite on your device.
- 3. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing Excel documents to enjoy a seamless experience.

Frequently Asked Questions
What does WindowState xlNormal do in VBA?
The xlNormal property in VBA restores the Excel application or active window to its default, unmaximized and unminimized size, which is required before developers can set custom Width and Height dimensions.
Why do my Width and Height VBA assignments fail?
If the window state is maximized or minimized, Excel locks the window dimensions. You must set the window state to xlNormal first. If the ActiveWindow method fails due to a bug, using Application.WindowState = xlNormal is an effective workaround.
Is this VBA window sizing issue a permanent change in Excel?
No, it has been identified as a regression introduced in a specific Microsoft 365 update. Microsoft typically investigates these issues and releases patches in subsequent update channels.




