Solved

Create MS Project files using .Net???

Posted on 2004-03-22
3
1,289 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

740 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