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.
 
Top