Golubin,
Your solution is not working.
I found the following code in MSDN which works
Private Function GetCurrentlySelectedProject() As EnvDTE.Project
Dim selItems As EnvDTE.SelectedItems
Dim selItemObj, selItem As EnvDTE.SelectedItem
Dim selProject As EnvDTE.Project
selItems = Me.m_application.SelectedItems
' List the number of items selected.
If selItems.Count > 0 And Not selItems.MultiSelect Then
' Set a reference to the first selected item.
selItemObj = selItems.Item(1)
' List the names of the project
' or project items under the selected
' item.
For Each selItem In selItemObj.Collection
If TypeOf selItem.Project Is EnvDTE.Project Then
selProject = selItem.Project
Else
If TypeOf selItem.ProjectItem _
Is EnvDTE.ProjectItem Then
If TypeOf selItem.ProjectItem.ContainingProject _
Is EnvDTE.Project Then
selProject = selItem.ProjectItem.ContainingProject
End If
End If
End If
Next
End If
Return selProject
End FunctionThanks,-Seeni
"Roman S. Golubin 1709176985" <(E-Mail Removed)> wrote in message
news:bp2l0m$qi3$(E-Mail Removed)...
>
> Hello, seeni
>
> > I have added a custom menuitem in the context menu (See attachment) to
> the
> > solution explorer
> > for a project. I require to read the target project name on clicking the
> > menu. I am unable to find any classes/functions to get the target
project
> > name(MBRClass - in my case) and project kind(CSproj or VBproj).
>
> Try this code:
>
> Imports EnvDTE
>
> Public Module Test
>
> Sub PrintProjNames()
> Dim projs As System.Array
> Dim proj As Project
> projs = DTE.ActiveSolutionProjects()
> For Each proj In projs
> MsgBox(proj.Name)
> Next
> End Sub
> End Module
>
>
>
|