Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create MS Project files using .Net???

Posted on 2004-03-22
3
1,272 Views
Last Modified: 2008-01-09
Hi all,

I have a project plan template that I would like to do the following:

1.  run a query to my MS Access table for project numbers and project status fields
2.  create a new .mpp file for each project number in query 1, based upon this template.
3.  change two fields in the new .mpp files to match the project numbers and project status fields from the query
4.  save the files on my local PC

(all work for this is done locally)

I have no idea of how to get started with this, except for the query.  So, I am looking for lots of help and code examples.
0
Comment
Question by:g118481
3 Comments
 
LVL 12

Accepted Solution

by:
esteban_felipe earned 500 total points
ID: 10655808
Hi g118481,

Well, you will have to write automation code for microsoft project. First add a reference to your project to "Microsoft Project 11 object library" (this is for project 2003, i would guess that project xp is microsoft project 10 object library). Then start suffering.. he he, sorry but writting automation code is always a pain. Here's a very small sample

using System;
using Project = Microsoft.Office.Interop.MSProject;
namespace ConsoleApplication22
{
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
      {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                  object objFalse = false;
                  Project.ApplicationClass objProject = new Microsoft.Office.Interop.MSProject.ApplicationClass();
                  objProject.Visible = true;
                  objProject.FileNew(Type.Missing,Type.Missing,Type.Missing,objFalse);
                  Project.Project myProject = objProject.ActiveProject;
                  myProject.Tasks.Add("test",Type.Missing);
                  myProject.SaveAs(@"c:\test.mpp",Project.PjFileFormat.pjMPP,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);

            }
      }
}

Prepare the debug and to "get creative" a lot. Sometimes when i have to do this kind of projects, I record macros in project and then study the generated code. This will save you a lot of time, as documentation is very vague.

Good luck :)


Esteban Felipe
www.estebanf.com
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question