Need help accessing BuiltInDocumentProperties from C#

J

Jason Reichenbach

I have a series of tasks to perform, some of which involve working with Word
using the COM interface from C#.NET.

I have one problem I have not solved yet: How to access individual elements
of the BuiltInDocumentProperties in a document.

BuiltInDocumentProperties is defined as an abstract object according to the
COM object browser. But I have not yet found what concrete objects are
derived from this, or how to access them from C#.

From VBA or vbScript it is pretty straight forward:

(vbScript)
docTitle = doc.Builtindocumentproperties (wdTitleField)

Where wdTitleField is a constant defined in the script file. However, in C#
this won't compile.

Any ideas will be most appreciated.

Jason

For example, I need to get the Title field.
 
J

Jonathan West

Hi Jason,

By opening the VBA editor in Word, you can find the value of the constant
easily enough - press F2 and search for it in the Object browser. I think
you have the wrong constant name - I think yoiu meant to refer to
wdPropertyTitle not wdTitleField. wdPropertyTitle has the value 1.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jason Reichenbach

Hi, Jonathan -

Thank you very much for your reply. My vbscript example was a subset of what
I really have, and is misleading, a bit. What I call wdTitleField is a
constant that is set to the value of wdPropertyTitle...

My apologies for leaving that out.

In any case, I found an excellent article in the Knowledge Base that answers
the question of how to do this in C#.

In case anybody else has this problem, check out

http://support.microsoft.com/?kbid=303296

Thanks again for your reply.
 

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