Pour VS2010 j'ai trouvé cette macro et elle fonctionne pour moi :
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Public Module Utilities
Public Sub TrackProjectItem()
Dim solution As Solution2 = DTE.Solution
If Not solution.IsOpen OrElse DTE.ActiveDocument Is Nothing Then Return
solution.FindProjectItem(DTE.ActiveDocument.FullName).ExpandView()
Dim FileName As String = DTE.ActiveDocument.FullName
Dim SolutionExplorerPath As String
Dim items As EnvDTE.UIHierarchyItems = DTE.ToolWindows.SolutionExplorer.UIHierarchyItems
Dim item As Object = FindItem(items, FileName, SolutionExplorerPath)
If item Is Nothing Then
MsgBox("Couldn't find the item in Solution Explorer.")
Return
End If
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem(SolutionExplorerPath).Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub
Public Function FindItem(ByVal Children As UIHierarchyItems, ByVal FileName As String, ByRef SolutionExplorerPath As String) As Object
For Each CurrentItem As UIHierarchyItem In Children
Dim TypeName As String = Microsoft.VisualBasic.Information.TypeName(CurrentItem.Object)
If TypeName = "ProjectItem" Then
Dim projectitem As EnvDTE.ProjectItem = CType(CurrentItem.Object, EnvDTE.ProjectItem)
Dim i As Integer = 1
While i <= projectitem.FileCount
If projectitem.FileNames(i) = FileName Then
SolutionExplorerPath = CurrentItem.Name
Return CurrentItem
End If
i = i + 1
End While
End If
Dim ChildItem As UIHierarchyItem = FindItem(CurrentItem.UIHierarchyItems, FileName, SolutionExplorerPath)
If Not ChildItem Is Nothing Then
SolutionExplorerPath = CurrentItem.Name + "\" + SolutionExplorerPath
Return ChildItem
End If
Next
End Function
End Module
Source originale aquí