Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / February 2004

Tip: Looking for answers? Try searching our database.

Error occur in accessing Word.Field.Data property.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandeep Sharma - 04 Feb 2004 04:53 GMT
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]
>
>.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.