VSTO Add-In Support for Project 2003 and Project 2007

VSTO Add-In Support for Project 2003 and Project 2007

  • Comments 9

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:

http://msdn2.microsoft.com/en-us/vstudio/default.aspx

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:

image

3. Give it a name and click OK

4. Add a Windows Form called SimpleDemoForm to the project:

image

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);
            frmSimpleDemoForm.Show();

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 System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MSProject = Microsoft.Office.Interop.MSProject;

namespace SimpleDemo
{
    public partial class SimpleDemoForm : Form
    {
        private MSProject.Application Application;

        public SimpleDemoForm(MSProject.Application Application)
        {
            InitializeComponent();
            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:

image

Chris Boyd

Leave a Comment
  • Please add 2 and 2 and type the answer here:
  • Post
  • Please find below sample code (thank you Mike Shughrue) in C# for a Project Professional 2007 COM Add-in.

  • Please find below sample code (thank you Mike Shughrue) in C# for a Project Professional 2007 COM Add

  • Hi,

    Can someone state the major advantage of using VSTO instead of current VS template to create an Add-in?

  • VSTO in Visual Studio 2008 provides add-in templates for Project 2003 and 2007, as well as easier integration with the other Office applications.

    Publishing the add-in to a network share with ClickOnce makes it very easy to distribute the add-in, handle security, and manage prerequisites and updates.

  • I just downloaded the Beta2 and installed the same just to get the first hand on VSTO for MSProject 2007.

    But after I installed VS 2008, i do not see the "Project Addin" entry in VS's New Project Dialog. (I do see entries for Word / excel etc)

    I have MSP 2007 installed. I have also installed PIO assemblies for 2007 just in case if its required.

    Any clue?

  • 罗列VSTO网络资源,还有使用VSTO做Project开发时遇到的问题

  • I need to get the values of a Lookup tables in COM add-in. How can i get it .. I am using Project server 2007 and project prof. 2007.

    I tried with CustomFieldValueListGetItem method..

    But i cannot get the required result..

    please anybody help me to get all the values of a Lookup table using COM add-in

  • Hi, i have a question, i create my aplication in msproject, but when i add resources or taks, visual show me an error  "Return argument invalid type.", what can i do to solve this???

  • For help with VSTO development in Project, please search for similar issues in the Project Customization and Programming forum, or ask a question there. social.msdn.microsoft.com/.../threads

Page 1 of 1 (9 items)