Hello
It’s possibe to select an replace text between two Bookmarks (BMStart, BMEnd) on an existing document?
[BMStarart]Text Text Text[BMEnd]
Regards
Hi Stefan,
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.Range.Bookmarks[“MyBookmark”];// Get the name and text of the bookmark.
string name = bookmark.Name;
string text = bookmark.Text;// Set the name and text of the bookmark.
bookmark.Name = “RenamedBookmark”;
bookmark.Text = “This is a new bookmarked text.”;
Hi
Thanks for your answer, but I think, it’s not exactly what I mean.
Situation:
An existing Word-Document has two Bookmarks - a start-Bookmark and an end-Bookmark. There is text between the Bookmarks. Now I have to get the Text between this two Bookmarks and replace it.
|This is Text|
^________^
| ________ Bookmark-End
Bookmark-Start
Here a sample how I used in in Office:
docword.Bookmarks.Item(“BMStart”).Select()
pos = docword.Bookmarks.Item(“BMStart”).Start
docword.Bookmarks.Item(“BMEnd”).Select()
pos2 = docword.Bookmarks.Item(“BMEnd”).Start
objword.Selection.SetRange(Start:=pos, End:=pos2)
objword.Selection.TypeText(“New Text”)
Kind regards
Hi Stefan,