Free Support Forum - aspose.com

Delete line after moving to bookmark?

I would like to movetobookmark and then delete the line the bookmark is on.

Is this possible?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can delete paragraph where bookmark is placed.

doc.Range.Bookmarks["book"].BookmarkStart.ParentNode.Remove();

Also you can remove content inside bookmark.

doc.Range.Bookmarks["book"].Text = string.Empty;

But you can’t remove particular line of the document. Aspose.Words document represents content and formatting of a document, not its layout into lines and pages. This feature is called pagination and it is not released yet. Please see FAQ for more information.

Best regards.

How do I write this using comHelper?

doc.Range.Bookmarks["book"].BookmarkStart.ParentNode.Remove();

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Please try using the following code:

'Create a ComHelper

Dim helper

Set helper = CreateObject("Aspose.Words.ComHelper")

'Open document

Dim Doc

Set Doc = helper.Open(Server.MapPath("in1.doc"))

'Remove bookmark content

Doc.Range.Bookmarks.Item_2("myBookmark").Text = ""

'Remove Bookmark

Doc.Range.Bookmarks.Item_2("myBookmark").Remove()

'Save document

doc.Save Server.MapPath("out.doc")

Hope this helps.

Best regards.