CustomDocumentPropertied and C#

J

Jeff

I want to be able to store a value in a field within a MS Project file.
I've come across CustomDocumentProperties and think is what I'm
looking for (correct me if there is another/better place).

I'm going to be creating the mpp with C# and need to be able to set the
value, then read the value at some other point. Does anyone have an
example of how to do this?

(I do have a reference to the Microsoft Office 11.0 Library)

Thanks
Jeff
 
J

Jeff

Solved....Here is what I ended up with:


//-------------------------------------------------------------------------------------
object oMissing = Missing.Value;
object oDocBuiltInProps;
object oDocCustomProps;

//Add a property/value pair to the CustomDocumentProperties
collection.
oDocCustomProps =
objProj.ActiveProject.CustomDocumentProperties;
Type typeDocCustomProps = oDocCustomProps.GetType();

object[] oArgs =
{"MyFieldName",false,Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeString,
"MyFieldValue"};

typeDocCustomProps.InvokeMember("Add", BindingFlags.Default
|
BindingFlags.InvokeMethod, null,
oDocCustomProps, oArgs);
 

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