Extra Bookmarks encountered

Hi,

I got this simple document file with 3 bookmarks added via Microsoft Word. When loaded into Aspose.Word, it gives me 4 bookmarks in the Range.Bookmarks. The last one duplicated but with path value “_GoBack”. It is not all documents have this, please advice.

Example code:

foreach(Bookmark bmark in doc.Range.Bookmarks)
{
.
.
.
.
}

Please find the attachment sample word document.

Hi Pei Ying,

Thanks for your inquiry. Your document contains four bookmarks, please see the attached image for detail. There is a hidden bookmark with name “_GoBack”. You can ignore or remove such bookmarks by using following code snippet. Hope this answers your query. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "AAA.docx");
foreach(Bookmark bm in doc.Range.Bookmarks)
{
    if (bm.Name == "_GoBack")
        continue;
    // your code...
}

----------------------------------------------

foreach(Bookmark bm in doc.Range.Bookmarks)
{
    if (bm.Name == "_GoBack")
        bm.Remove();
    // your code...
}