|
| ||||||||||
| Tags: c sharp, dll file, ms project, server, sql server database |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Read MS Project files from C#
|
|
#2
| ||||
| ||||
| Re: Read MS Project files from C#
Below is the method how I went about reading a Microsoft Project file in C#: using Microsoft.Office.Interop.MSProject; using System.Reflection; ApplicationClass projectApp = new ApplicationClass(); // Open the file. There are a number of options in this constructor as you can see projectApp.FileOpen("C:\myfile.mpp", true, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, PjPoolOpen.pjDoNotOpenPool, Missing.Value, Missing.Value, Missing.Value, Missing.Value); // Get the active project Project proj = projectApp.ActiveProject; // Enumerate the tasks foreach (Task task in proj.Tasks) { string name = task.Name; // Project stores the number of minutes in a workday, so 8 hours per workday * 60 = 480. 480 is a project "day" int duration_in_days = Int32.Parse(task.Duration.ToString()) / 480; DateTime start = DateTime.Parse(task.Start.ToString()); DateTime finish = DateTime.Parse(task.Finish.ToString()); double percent_complete = Double.Parse(task.PercentComplete.ToString()); DateTime actual_finish = DateTime.Parse(task.ActualFinish.ToString()); // Do something with each task here } // Make sure to clean up and close the file projectApp.FileCloseAll(PjSaveType.pjDoNotSave); A pretty simple example, but I could not find a single example of doing this online. Projectin' Tom Out. |
|
#3
| |||
| |||
|
Hi JAMES_911, Very useful your post. Please, one doubt... when I try to compile I receive this error message: "The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)" Is it necessary install a DLL ? Thanks, best wishes. Daniel |
|
#4
| |||
| |||
| Re: Read MS Project files from C#
Hi daniel.aquere, The error that you are getting is mainly due to PIA's (primary interop assemblies) not registered to the GAC for XP or any version of Windows. You just got to add the dlls in the following download or register the dlls through visual studio command prompts. The error is coming because you don't have the proper reference. In this case it very well could be due to differing versions. |
|
#5
| |||
| |||
Re: Read MS Project files from C#
Hi Janos, Thanks for response. Please, where I find the DLL mentioned to install? Best Daniel |
|
#6
| |||
| |||
| Re: Read MS Project files from C#
Hi daniel.aquere, I think that you can use xp PIAs for 2000, check the below link for same: http://www.microsoft.com/downloads/d...displaylang=en |
|
#7
| |||
| |||
Re: Read MS Project files from C#
Hi Janos, Thank you very much. I´m using 2007 version, it´s working very fine. Best Daniel |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Read MS Project files from C#" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Migrate .mpp files from Project 2003 to Project 2010 | Skylar | Microsoft Project | 4 | 26-03-2012 06:42 PM |
| Does Kindle DX read .doc files? | Ramirez | Portable Devices | 6 | 22-02-2011 01:02 AM |
| Can copy and read the new files but cannot read or delete old contents in the hard drive | GOOL | Hardware Peripherals | 3 | 14-12-2010 03:10 AM |
| Unable to read avi files | Axton | Windows Software | 3 | 13-04-2009 11:57 AM |
| Read MAG files of images | Parker | Windows Software | 3 | 20-03-2009 12:39 PM |