Bookmarks.Remove does not remove the bookmark using .NET

doc.Range.Bookmarks.remove(bookmarkname) does not work.

also tried clear(bookmarks) which did not help either.


Please ZIP and attach your input Word document and bookmark name that you want to remove. We will investigate the issue and provide you more information on it.

Hello Tahir, Attached are the requested files and please note that the resulting document from following code still has the original bookmarks defined. Thank you. Lakshmi

                                                            Aspose.Words.License license = new Aspose.Words.License();


                                                            Aspose.Words.Document doc = new Aspose.Words.Document(path + "Mail_Template.docx");

                                                            DocumentBuilder builder = new DocumentBuilder(doc);

                                                            foreach (Bookmark bm in doc.Range.Bookmarks)


                                                                            Aspose.Words.BookmarkStart bookmarkStart = bm.BookmarkStart;

                                                                            Aspose.Words.BookmarkEnd bookmarkEnd = bm.BookmarkEnd;

                                                                            string bmName = bm.Name;

                                                                            string bmText = bm.Text;

                                                                            switch (bmName)


                                                                                            case "ENTITYNAME":

                                                                                                            bmText = dr["OwnerName"].ToString();


                                                                                            case "ENTITYADDRESS":

                                                                                                            bmText = dr["Address1"].ToString();


                                                                                            case "ENTITYCITYSTATEZIP":

                                                                                                            bmText = dr["Address2"].ToString();


                                                                                            case "TODAYSDATE":

                                                                                                            bmText = DateTime.Today.ToShortDateString();


                                                                                            case "DUEDATE":

                                                                                                            bmText = dr["Due_Date"].ToString();


                                                                                            case "LICNUM":

                                                                                                            bmText = dr["licno"].ToString();


                                                                                            case "TOTALAMOUNT":

                                                                                                            bmText = dr["total"].ToString();


                                                                                            case "SUBTOTAL":

                                                                                                            bmText = dr["subtotal"].ToString();


                                                                                            case "RETPMTFEE":

                                                                                                            bmText = dr["retfee"].ToString();



                                                                            builder.MoveToBookmark(bmName, true, true);





                                                            doc.Save(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "[\\templetters\\](file://templetters/)" + letterid + ".docx"); (68.3 KB)


We have faced the compile time errors with your code. If you want to remove the bookmarks from the document, please use the following code example.

Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Mail_Template.docx");
doc.Save(MyDir + "20.10.docx"); 

If you want the specific bookmark, please attach the following resources here for testing:

  • Please share the bookmark name.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.