Locate Project Item in Solution Explorer – Improved
Posted by Dan Vanderboom on August 24, 2010
Way back in March 2008, I wrote an article sharing a macro to locate the current document in Solution Explorer without having to have the annoying setting “Track current item in Solution Explorer” always turned on. I map this to my F1 key (I get my help online) and all is good in the world.
When I wrote this macro, I remember reading some documentation for VS2003 or VS2005 saying that it wasn’t possible to update this “Track current item” setting programmatically. This has changed, and in VS2008 and VS2010 these can indeed be triggered programmatically. Rob posted the much abbreviated code in one of the comments.
Public Sub TrackProjectItem() DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer", True) DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer", False) DTE.ExecuteCommand("View.SolutionExplorer") End Sub
Thanks to Rob and all the others who left comments on that article.

huaj said
I found a problem in the macros above
When solution is complex, that means nested solution folders, tens of projects,
It seems the UIHierarchyItems is lazy load
So, if some project is not expanded manually yet, it cannot be located
Have some ideas on it?