In ms word2010 I have a bookmark with bookmark name: nameOfBookmark
Now the bookmark content could be anything from just text to a mix of pictures, tables and whatever you could think of putting in a word document.
The problem is as following: I've got my bookmark with some contents I want to delete. However each time I try to delete the contents it also deletes my bookmark which I want to keep.
I've tried this, which simply deletes the whole thing:
public void cleanBookmark(string bookmark)
{
var start = currentDocument.Bookmarks[nameOfBookmark].Start;
var end = currentDocument.Bookmarks[nameOfBookmark].End;
Word.Range range = currentDocument.Range(start, end);
range.Delete();
}
I've also tried to set the range to this:
Word.Range range = currentDocument.Range(start +1, end -1);
But then I end up with a bookmark that still contains the first and the last character of the content I wanted to delete.