Tuesday, February 17, 2009

Microsoft Project and Inserting Columns

I am doing a LOT of work right now with SAS and Microsoft Project using the Microsoft Project interop, Base SAS, and SAS/IntrNet. One of the client requirements was to add in additional columns to the default MS Project columns. Well, I searched high and low and couldn't figure out how to do it. After some slogging, here is what I came up with:



class MsProjectTest
{
Project p ;
object m = Missing.Value;
string file = @"c:\temp\test.mpp";

public void Process()
{
Application app = new Application();
app.Alerts(false);
p = app.Projects.Add(m,m,m);
Task t = p.Tasks.Add("Test", m);
t.Name = "Test Node";
t.Start = "03/20/2009";
t.Start7 = "03/31/2009";
p.Application.TableEdit("Entry", true, m, m, m, m,
"Start7", "Start Test", 10, PjAlignment.pjLeft,
true, true, 255, 1, 4, 1, m, m);
p.Application.TableApply("Entry");
p.SaveAs(file, PjFileFormat.pjMPP, m, m, m, m,
m, m, m, m, m, m, m, m, m);
app.Quit(PjSaveType.pjDoNotSave);

System.Diagnostics.Process.Start(file);
}
}



I hope this helps some other interop developer out
there struggling with the same issue.

No comments:

SAS throwing RPC error

If you are doing code in C#  and get this error when creating a LanguageService: The RPC server is unavailable. (Exception from HRESULT:...