Solved

Create MS Project files using .Net???

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Single Form 8 42
Capture logon name 13 73
Please explain the parts of these 2 LINQ expressions 3 30
Expression Evaluater 3 25
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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