Close all code windows/panes in VB Editor

Brian.Crawford

Board Regular
Joined
Oct 3, 2007
Messages
136
Whenever I open the VB Editor all the code windows for (almost) all my add-ins and personal WB always open and totally clutter-up my current project. Is there a way to automatically close them ALL (I'd individually re-open the current project ones I need to work with) at once when the VBE opens or a macro I could run to close them at least until Excel closes.
Have done some searching on this but to no avail.

thanks all
Brian
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Could try something like this;
I am not familiar with coding in the VBE, but this seems to close all but one.

Code:
Sub CloseCodePanes()
Dim i As Integer
    On Error Resume Next
    For i = Application.VBE.CodePanes.Count To 1 Step -1
        Application.VBE.CodePanes(i).Window.Close
    Next i
End Sub
 
Upvote 0
Well, one is better than 100.
Interestingly though, when I ran it with many windows open it did leave one open, however when I ran it with just a few (4) it got rid of all of them.
Appreciate this a lot .. I've put up with this for so many years, just never took the time to find a solution.

Any thoughts on how I could trigger it automatically when the VBE opens
thanks again
Brian
 
Upvote 0
I had to ask your question in the forum I frequent in as I needed to get advice regarding triggering the macro automatically.

See the replies from Hans (our resident guru and Admin) at Eileen's Lounge, here for some good suggestion...
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top