Solved

Create MS Project files using .Net???

Posted on 2004-03-22
3
1,322 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
[X]
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
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

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:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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