« About using PowerPoint...VSIP 2005: Tracking the active VS window »

Accessing project properties from a VS macro

04/09/05

Permalink 06:03:40 pm
Categories: General, Programming, .NET, VSIP

Accessing project properties from a VS macro

I saw this question on a newsgroup: How do you access the properties of a project via the EnvDTE VS extensibility interface? It's really quite simple, like in this code:

Sub AccessProject()
  Dim proj As Project
  proj = DTE.Solution.Projects.Item(1)
  Dim prop As [Property]
  For Each prop In proj.Properties
    Debug.Print("Project property " & prop.Name & " = " & prop.Value)
  Next
  Dim projItem As ProjectItem
  For Each projItem In proj.ProjectItems
    Debug.Print("Project item " & projItem.Name)
  Next
End Sub

This will simply print out all the project properties and items it finds. The sample accesses only the first entry in the solution's Projects list - you can directly access other specific members in a similar way, of course, and it's also possible to find the currently active project(s) via the DTE.ActiveSolutionProjects:

Dim projects as System.Array = DTE.ActiveSolutionProjects
Dim proj as Project

For Each proj In projects
  Debug.Print(proj.Name)
Next

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
Please complete the song title below. Hint: enter 'h', 'e', 'a', 'v', 'e', 'n'
antispam test

Enter your email address:

Search

Oliver
MVP logo
March 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31