Nick Vittum
New Member
- Joined
- Apr 2, 2020
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
This may be a "Duh!" to the rest of you, but it seems I never noticed it before: If the Excel window is minimized, and you're working in VBA editor, and then you close the editor, the Excel WindowState changes to xlNormal.
Currently I'm working on a Workbook that remains minimized most of the time (data entry is all done through a userform). While I'm tweaking the workbook, I'm opening and closing the VBA editor frequently. I want to prevent the Excel WindowState from changing: if I have it minimized, I want it to stay that way (and for that matter, if I have it Maximized, I want it to stay that way).
I'm not sure exactly what code to write to prevent this, and more importantly, not sure where to put it. I tried putting this in the Workbook's "Workbook_WindowResize" event, just to see if that was the right place—
As might be expected, that prevented the Excel window from showing at all unless the VBA window was also visible (just a .1 second flash, if I tried to show it). So then I tried replacing that bit with this—
—but this time the result was nothing at all.
So: Is there an actual "Close Window" event for the VBA window somewhere, where I should be putting this code? And/or how can I reword my code to get the effect I want?
Thanks!
Currently I'm working on a Workbook that remains minimized most of the time (data entry is all done through a userform). While I'm tweaking the workbook, I'm opening and closing the VBA editor frequently. I want to prevent the Excel WindowState from changing: if I have it minimized, I want it to stay that way (and for that matter, if I have it Maximized, I want it to stay that way).
I'm not sure exactly what code to write to prevent this, and more importantly, not sure where to put it. I tried putting this in the Workbook's "Workbook_WindowResize" event, just to see if that was the right place—
VBA Code:
If Application.VBE.MainWindow.Visible = False Then Wn.WindowState = xlMinimized
Code:
If Application.VBE.MainWindow.Visible = False And Wn.WindowState = xlMinimized Then
Wn.WindowState = xlMinimized
So: Is there an actual "Close Window" event for the VBA window somewhere, where I should be putting this code? And/or how can I reword my code to get the effect I want?
Thanks!