Hi Team, i am trying to get data inside of bookmark . But unable to get
Please find attached word document
Bookmarkword.zip (19.6 KB)
Code:
Document doc = new Document(fname);
DocumentBuilder builder = new DocumentBuilder(doc);
foreach (Bookmark bookmark in doc.Range.Bookmarks)
if (bookmark.Name.StartsWith("_"))
bookmark.Remove(); // remove hidden bookmarks
builder.MoveToDocumentEnd();
builder.StartBookmark("DocumentEnd");
builder.EndBookmark("DocumentEnd");
BookmarkCollection bmCollection = doc.Range.Bookmarks;
string bookmarkName = string.Empty;
string bookmarkHtml = string.Empty;
for (int i = 0; i < bmCollection.Count - 1; i++)
{
Bookmark bookmark = doc.Range.Bookmarks[i];
bookmarkName = bookmark.Name;
if (bookmarkName == "PR_Title")
{
obj.PressReleaseTitle = bookmark.Text; //sb.ToString();
}
else if (bookmarkName == "PR_Overview")
{
obj.Overview = bmCollection[i].Text;
}
}