I am very excited about the Visual Studio Beta 2 release, as it now has support for Project 2003 and Project 2007 add-ins! This makes coding and debugging managed code very easy in Project Client. It also makes it really simple to call into the PSI from Project Client to retrieve and update data on the server because you have the complete .Net framework at your disposal.
You can download Visual Studio Beta 2 to try it out for yourself:
I plan to do a few complex blog posts with regards to VSTO over the next couple of months, but to get started, here is a basic example:
1. Download and install VS Beta 2 from: http://msdn2.microsoft.com/en-us/vstudio/default.aspx
2. Open VS Beta 2 and Create a New Project selecting Project Add-in:
3. Give it a name and click OK
4. Add a Windows Form called SimpleDemoForm to the project:
5. A label to the form called: lblProjectName
6. In the ThisAddIn.cs class file add the following code in the startup method:
SimpleDemoForm frmSimpleDemoForm = new SimpleDemoForm(Application);
This code will load and show the form we created in step 4. Note that we pass the Application into the form's constructor.
7. View the code for the form and have it match the following:
using MSProject = Microsoft.Office.Interop.MSProject;
public partial class SimpleDemoForm : Form
private MSProject.Application Application;
public SimpleDemoForm(MSProject.Application Application)
this.Application = Application;
private void SimpleDemoForm_Load(object sender, EventArgs e)
lblProjectName.Text = Application.ActiveProject.Name;
Couple of things to note with this code sample. We have referenced Microsoft.Office.Interop.MSProject and we have passed the Application variable to the form so that we can manipulate the project in the same way we can manipulate it in VBA. In the form load method, we read the project name and show it on the form.
8. Build and run the application.
This should launch Project automatically and load the add-in for you, with no configuration work involved. You can also add any debug breaks to troubleshoot your code.
Here is what you should see when you build and run the add-in: