How do I get / Set the Properties of an Active Word Document ?

My Appliacation displays an instance of Word in a custom control on a WinForm. The surrounding WinForm displays extra details about the actie document being tracked by my application. One of the extra bits of information is the Document Properties of the Active Document (currently retrieved using DSOleFile.dll). BUT, my app needs to be able to update the Document Properties while the Document is still open. I can't do this with DSOleFile.dll because of a file open lock on the Document.

I have found some examples of getting / setting the Document Properties using VB / VBA and VSTO but not C#.

I can get to the object "objWinWordControl.WordAppClass.ActiveDocument.BuiltInDocumentProperties" but I can't find a way to access the subject, comment or template properties that I need.

Does anyone have any example code of how to get / set Document Properties of an ActiveDocument open in Word ?
VoicepathAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

irudykCommented:
Does the following not give you what you need:
Read/Write items:
objWinWordControl.WordAppClass.ActiveDocument.BuiltInDocumentProperties("Subject");
objWinWordControl.WordAppClass.ActiveDocument.BuiltInDocumentProperties("Comment");
Read only item:
objWinWordControl.WordAppClass.ActiveDocument.BuiltInDocumentProperties("Template");
0
irudykCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VoicepathAuthor Commented:
Thanks for the input irudyk,
Using your first suggestion; BuiltinProperties("Subject") gives me an error "is a Property but is used like a method".
The link you sent worked nicely once I'd changed all the object names and I found BindingFlags in System.Reflection. But what a palava just to get the property of an avtive document !!
 
A Thousand Thanks to you irudyk.
0
VoicepathAuthor Commented:
Thanks again Irudyk.
Have a good day.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.