In the context of an Outlook add-in using WordEditor from Outlook.Inspector, I would like to remove this selection after replacing it with custom text.
For example, if I select something, I can change the selection to custom text as follows:
Word.Selection sel = doc.Windows[1].Selection; Word.Range range = sel.Range; if(sel.Text.Length == 0) { MessageBox.Show("No Text is selected"); return; } sel.Text = "New Text"; sel.Collapse();
If I call this function again, now sel.Text.Length will be 1 instead of 0.
source share