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?
OK this was ridiculously easy in the end.
oWord.Selection.TypeBackspace();//remove the field
oWord.Selection.TypeBackspace();//remove the line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With