Creating a new mpp file from C#

L

linsen

Hi,
I want to create a mpp file in ms project using c#. For this purpose, i
created 2 tables "project" and "tasks". Project has the fields projectid and
projectname and tasks has the fields taskid, taskname and projectid.
Currently my code structure is like this.

select projectid,projectname from project.
{
add projectname as the summary task.
Then select all the tasks which has the above projectid(assume some 20
tasks are there).
{
Add this as the child task.
}
}

This code works fine. But the issue is that it takes one minute for each
iteration. So if 200 projects are there, then it takes 200 minutes. Please
suggest some ways by altering the query so that i can speed up the process.
 
A

Adam Behrle

Hi Linsen,

This is pretty open ended, and can depend on a lot of factors. If your
bottle neck is the automation of MS Project then this might help a
little:

//Before automation begins, set the following fields

//Don't perform auto calculations
projectApp.Calculation = pjManual;

//Hide the application
projectApp.Visible = false;

//Don't update the screen on changes
projectApp.ScreenUpdating = false;

//Don't display windows in task bar
projectApp.DisplayWindowsInTaskbar = false;

Hope this helps a little....

Adam
 
R

Rod Gill

Where is most time being spent, creating the new project, adding tasks or
saving?

In VBA 20 tasks would take less than 1 second but obviously inter-process
commands are much slower. In fact that is one way of going quicker: Have VBA
code to read from the database and create your projects and tasks and call
the vba macro from C#. The VBA code would live in the Global.mpt file.

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top