how to enumerate custom properties?

H

Heidi

I'm trying to enumerate the custom properties on a word document using C# and
I am not having any luck. Does anyone either have an example or know where I
am going wrong?

I've been trying variations on the following:
CustomProperties properties = (CustomProperties)
wrdDoc.CustomDocumentProperties;

//System.Collections.IEnumerator pEnumerator = properties.GetEnumerator();
//for (int i=0;i< properties.Count;i++)
foreach (CustomProperty thisProperty in (CustomProperty)properties.GetItems())
{
//CustomProperty thisProperty = (CustomProperty)
Microsoft.Office.Interop.Word.get_item( i);
//CustomProperty thisProperty = (CustomProperty) properties;
string pName = thisProperty.Name;
string pValue = thisProperty.Value.ToString();
string pType = thisProperty.Value.GetType().FullName;
pType = string.Empty;
}


getEnumerator shows up in intellisense but won't compile. if I try to use
properties I get an error that says I should try to access get_item
directly but I get a compiler error from that - and it doesn't show up in
intelllisense.

thanks!
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?SGVpZGk=?=,
I'm trying to enumerate the custom properties on a word document using C# and
I am not having any luck. Does anyone either have an example or know where I
am going wrong?
Search the Knowledge Base on the msdn site at microsoft.com. There is an article
in there dealing with automating custom doc props using C#

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
H

Heidi

Yes, I had seen this article but I was hoping for something that was simpler
to read and maintain. I decided to use the component microsoft has made
available for setting properties on documents. In the end, it fit better into
the structure of my project.

Thanks for your time,
Heidi
 

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