Tidying Up the Project Explorer

You know that pressing Ctrl+R in the VBE takes you to the Project Explorer. Of course you do. I’m not going to sit here and insult your intelligence by pretending that you don’t. But that means you are probably also just as confused as I am about which projects the VBE “chooses” to expand and which stay closed.

I have a lot of add-ins and that makes my Project Explorer very messy. Ideally I want the active project to be expanded and everything else collapsed. But I can’t have that. I decided I’ve had enough and added the following hotkey to my AutoHotKey VBE.ahk file.

Send ^r
Send {End}
Loop 20 {
Send {Left 2}{Up}

When I’m in the VBE (an IfWinActive condition in VBE.ahk) and press Ctrl+Shift+R, the focus goes to the Project Explorer, goes to the last project, then closes up to 20 of them. Two left arrows will collapse an expanded project and has no effect on a collapsed project. The up arrow goes to the next project. Genius, you say? I humbly agree.

I don’t keep my modules in Folders (Toggle folders using the button at the top of the Project Explorer). If you do, you’ll need to change the {Left 2} to {Left 4}.

5 thoughts on “Tidying Up the Project Explorer

  1. Nigel, I’d say none. All the files in the pic except one are addins.

    Dick, one interesting thing is that protecting the VBA project seems to ensure that it’s collapsed. Might even be the best reason to protect a project since the security is as weak as it is anyway. ;)

  2. Right, none. I just have that many add-ins open all the time. None are very big, I just like my code to be nice and segmenty.

    I used to protect my projects, but no more. Typing in the password (even Chip Pearson’s infamous ‘a’) was too much of a pain.

  3. Thanks Edouard. I didn’t know MZ Tools had that option. I could have used it like this

    I am trying to decrease my reliance on MZ Tools so I can switch to 64-bit Office, so I’ll be sticking with AutoHotKey.

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.