logo
search
VBA & Macro Problems

How to Fix Excel VBA WindowState xlNormal Bug After Excel Was Maximized

Partner EditorPartner Editor Sep 28, 2026 868 views

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.

How to Fix Excel VBA WindowState xlNormal Bug After Excel Was 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.
Before you start

Verify your current Microsoft 365 build version and save a backup of your VBA project before testing any automation code modifications.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 in Excel to open the Visual Basic for Applications (VBA) editor.

2
Locate the Window Sizing Code

Find the module and the specific macro where you are attempting to set the ActiveWindow.WindowState and window dimensions.

3
Modify the WindowState Reference

Insert or change the code to read 'Application.WindowState = xlNormal' before you assign the Width and Height properties.

4
Test the Automation

Save the changes and run the macro to ensure the Excel window restores to a normal state and resizes correctly.

Use Application.WindowState as a Workaround
Dimension Assignments: Once the application is forced into the xlNormal state, your subsequent Height and Width property assignments will work as intended.
Free Microsoft Office alternative

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. 1. Download the Software: Visit the official WPS Office website and click the free download button.
  2. 2. Install WPS Office: Run the setup file and follow the on-screen instructions to install the suite on your device.
  3. 3. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing Excel documents to enjoy a seamless experience.
Fully compatible with Microsoft Excel formats including .xlsx, .xls, and .csv.Stable environment that minimizes sudden update regressions during workflow.Lightweight architecture ensures fast startup and smooth operation.Familiar user interface requires virtually no learning curve.
microsoft office alternative - wps office

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.