How Read CustomdocumentProperties Using C#

C

Charitha

Hi
I have to read customdocument properties from the document.Actually It is
acollection in the doucment.
I have implmented code in this way
Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing, ref
falseValue, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref isVisible, ref missing, ref
missing, ref missing, ref missing);
aDoc.Activate();

object oDocCustomProps = aDoc.CustomDocumentProperties;
Type typeDocCustomProps = oDocCustomProps.GetType();

//Here I am getting the count
int cnt = (Int32)typeDocCustomProps.InvokeMember("Count",
BindingFlags.Default | BindingFlags.GetProperty, null, oDocCustomProps, new
object[] { });

But How to read Customdocument property name from the Collection?
for (int i = 1; i <= cnt - 1; i++)
{

string strIndex = i.ToString();

object obj = typeDocCustomProps.InvokeMember("Get_Item",
BindingFlags.Default |
BindingFlags.InvokeMethod,
null, oDocCustomProps,
new object[] { strIndex });
}

Here I am getting com error like Disp Unknown name.
Can anybody help me how to read the customdocumetproperties names?
 

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