Accessing field by Name instead of Index

N

Nirmalkumar

Hi,

I hvae one MS-Word document, which has some merge fields. in VB.NET i need
to update these fields with data from DB.

But while accessing i want to access the field by name instead of index.
objSrcFromDoc.Fields.Item(1).Result.Text = "Data from DB".

Here we are accessing by Index, but i need to access by field name.

Is there any way.

Please help me.

Nirmal.
(e-mail address removed)
 
C

Cindy M.

Hi =?Utf-8?B?TmlybWFsa3VtYXI=?=,
I hvae one MS-Word document, which has some merge fields. in VB.NET i need
to update these fields with data from DB.

But while accessing i want to access the field by name instead of index.
objSrcFromDoc.Fields.Item(1).Result.Text = "Data from DB".

Here we are accessing by Index, but i need to access by field name.
There is no way to do this. Mergefields were NOT designed to be addressed by
anything but the mail merge process in Word. Bookmarks were designed to be
addressed by name when automating Word to insert data.

I'm afraid you have no choice but to loop through the collection of fields in
the document, check the type, extract the name from the code, then insert the
appropriate data.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 

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