We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding new Bookmark after existing bookmark

I have an existing word doc that currently contains bookmarks. I need to locate a specific existing bookmark and add new ones below it.

I can find the existing bookmark by using the MoveToBookmark method. I then add the new bookmark name by using the StartBookmark and EndBookmark methods.

The problem that I run into is that all the new bookmarks that I add are ending up within the first bookmark that I searched for. I would like the new bookmarks to appear after the existing one.

What do I need to do once I've found the starting bookmark?

Thank You.

Hi Howard,


Thanks for your inquiry and sorry for the delayed response. You can use the following code snippet to move the cursor to be after the ending of the bookmark,

Document
doc = new Document(@“C:\Temp\in.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToBookmark("previous", false, true);

builder.StartBookmark("next");

builder.Write("inside next");

builder.EndBookmark("next");

doc.Save(@"C:\Temp\out.docx");


I hope, this helps.

Best regards,