Platform is MSP 2007, connecting to Project Server. Code written in C#, VS 2010 + VSTO
I've found links and snippets of source code on this forum written by Rod Gill. They don't seem to work in my case.
The code is below:
PjField WorkCode;
Task newTask;
WorkCode = Application.FieldNameToFieldConstant("ERP Work Code", PjFieldType.pjTask);
newTask = ActiveProject.Tasks.Add("Work Task Example");
newTask.SetField(WorkCode, "WC"); // this Fails with "The argument is not valid" exception
// Also tried, also fails:
// ActiveProject.Tasks[newTask.Index].SetField(WorkCode, "WC");
Thanks for your help
Marc