Visual Studio: Collapse All Solution Explorer

Sometimes you have to open very big solution files in Visual Studio; but when Visual Studio opens these big solutions, by default they are all expanded in the Solution Explorer window, so that you can see only a few projects, and you would like to collapse them all.

For this reason, I did some researches and found that Visual Studio hasn't a native command to do this, and so a dedicated macro is needed.

I found one in the post Collapse all Solution Explorer items in Visual Studio 2010: it is very good because the author comments how to install it also.

I've modified it, to ensure that the macro works after the project has been opened and you have worked in it, so that even if you expand projects and then collapse their parent nodes, the modified macro collapses all the projects correctly.

You can download the file modified by me in the file CollapseAllSolutionExplorer.vb.txt (I suggest you don't open it in your browser, but save it locally)