In the template there are two bookmark called “Heir” and “possibleheir” and we are removing only the content of bookmark when bookmark is “Heir” so as per the code it should only remove the content of bookmark “Heir” and should leave bookmark called “possibleheir” as it is but when statement highlighted in yellow section is executed It removes another bookmark called “possibleheir” and It should not be.
public void checkBookMark(Document docMain)
{
BookmarkCollection oBookmarkCollection = docMain.Range.Bookmarks;
//Fetching all bookmarks
foreach (Bookmark bookmark in oBookmarkCollection)
{
if (bookmark.Name != “_GoBack”)
{
BookmarkStart bookmarkStart = bookmark.BookmarkStart;
BookmarkEnd bookmarkEnd = bookmark.BookmarkEnd;
if (bookmark.Name == “Heir” || bookmark.Name != “possibleheir”)
{
bookmark.Text = “”;
//once this line is executed It removes bookmark called ‘possibleHeir’
}
}
}
}
Other Information:
- Aspose Library & version: Aspose.Words 19.7.0.0 (Aspose.Words for .NET)
- Programming language: C#
I am not able to upload word template here. Can you please share your e-mail or suggest some other way so that I can send you the word template document
I am your paid customer. Please helpTest_Bookmark - Complaint.zip (20.7 KB)