How do I walk all the merge fields in a doc document from C#

R

Raul

Hi there,

I have a word doc with a few mail merge fields, some of those fields are
inside text boxes.
But I can get to those merge fields inside the text boxes.

here is a piece of the code i use
Enumerators oFielsEnumerator = _oWordDoc.MailMerge.GetEnumerator();
while(oFieldEnumerator.MoveNext)
{
WordMailMergeField field = oFieldEnumerator.Current as
Word.MailMergeField;
field.Select();
Word.Range FieldRange = _oWordApp.Selection.Range;
string strField = FieldRange.Text;
// this will show the merge fields with the << >>
}


Any advise is welcome.
Raul.
 

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