Solved

Create MS Project files using .Net???

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now