I have some code to find and replace fields in a word document with values from a dataset.
Word.Document oWordDoc = new Word.Document();
foreach (Word.Field mergeField in oWordDoc.Fields)
{
mergeField.Select();
oWord.Selection.TypeText( stringValueFromDataSet );
}
In some cases stringValueFromDataSet is empty, and in addition to inserting nothing, I want to actually delete the current line.
Any idea how I can do this?
Obviously, your answer works in your case. However in the general case (where the
entire line cannot be removed using a backspace) the following can be used: