Hi,
I have a custom property name "test" whose value
is "great" in one of my word document which is in word
2000.
I am opening the word document thru a c# application and
then added that field into the document using following
code.
Word.Selection sln = aDoc.ActiveWindow.Selection;
(aDoc.Paragraphs.Count).Range;
object fieldType = Word.WdFieldType.wdFieldEmpty;
object text = "DOCPROPERTY \"test\" ";
object objTrue = true;
Word.Field fld;
fld = sln.Fields.Add(sln.Range, ref fieldType, ref text,
ref objTrue);
MessageBox.Show("Field data " + fld.Data); //runtime error.
I want to access the value (data) of this field "test" and
used Field.Data property which gives a runtime error.
Pls advise what I am doing wrong. How can i access data of
a property.
Thanks.
Cindy M -WordMVP- - 04 Feb 2004 11:24 GMT
Hi Sandeep,
> MessageBox.Show("Field data " + fld.Data); //runtime error.
>
> I want to access the value (data) of this field "test" and
> used Field.Data property which gives a runtime error.
the Field object in Word has no DATA property, unless the
feild is an ADDIN field (read up on the property in Word's
Help!)
Try the RESULT property, instead.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
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 :-)
Sandeep - 05 Feb 2004 14:26 GMT
Thanks a lot.
field.Result.Text is what I wanted.
thx / sandeep
>-----Original Message-----
>Hi Sandeep,
[quoted text clipped - 20 lines]
>
>.