I have a workbook that, among other things, minimizes on opening using the VBA command, Application.WindowState = xlMinimizes, in the Workbook_Open macro.
This worked for years until recently when it began to restore the workbook window to its last size. The restore happens the moment the Workbook_Open subroutine completes. I've verified this by placing an Msgbox command at the very last command in Workbook_Open.
Thinking I may have inadvertently caused this problem via a change one of my macros (it has quite a few) I set a breakpoint, reopened the workbook and single-stepped through the code (F8). The second it hit the End Sub the workbook restored from its previous minimised state.
I also created a new macro enabled workbook with only 2 commands in the Workbook_Open macro in the Thisworkbook module:
Application.windowstate = xlMinimized
Msgbox "Pause"
On loading, this test workbook minimizes as expected, presents the message box. But as soon as I respond to the message box, the workbook automatically restores on the display.
Most interestingly, if I subsequently manually execute the Workbook_Open macro in VBE(run or step), it behaves properly and stays minimized.
I simply cannot figure out what is happening. Perhaps there is some setting in the Excel Options, but I just don't know.
Appreciate any help.
This worked for years until recently when it began to restore the workbook window to its last size. The restore happens the moment the Workbook_Open subroutine completes. I've verified this by placing an Msgbox command at the very last command in Workbook_Open.
Thinking I may have inadvertently caused this problem via a change one of my macros (it has quite a few) I set a breakpoint, reopened the workbook and single-stepped through the code (F8). The second it hit the End Sub the workbook restored from its previous minimised state.
I also created a new macro enabled workbook with only 2 commands in the Workbook_Open macro in the Thisworkbook module:
Application.windowstate = xlMinimized
Msgbox "Pause"
On loading, this test workbook minimizes as expected, presents the message box. But as soon as I respond to the message box, the workbook automatically restores on the display.
Most interestingly, if I subsequently manually execute the Workbook_Open macro in VBE(run or step), it behaves properly and stays minimized.
I simply cannot figure out what is happening. Perhaps there is some setting in the Excel Options, but I just don't know.
Appreciate any help.