This class is used to represent a bookmark in the document. Bookmarks can be added to a document in Word or programmatically using WordWriter. They can only be retrieved form an existing document.

 public sealed class Bookmark : Element
Public NotInheritable Class Bookmark
		Inherits Element

To insert a bookmark into a document, use Element.CreateBookmark() or Table.CreateBookmarkOnRow(). To get a bookmark from an existing document use the Document.GetBookmark method.

The following sample shows you how to add a bookmark to a document and retrieve a bookmark from a document.


          //--- Create a bookmark
          WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\sample.doc");
          doc.CreateBookmark("MyBookmark");

          //--- Get an existing bookmark
          WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\sample.doc");
          Bookmark bmark = doc.GetBookmark("ExistingBookmark");

          //--- Or, if you know the order of the bookmarks in the document
          //--- you can use the following:
          //Bookmark bmark = (Bookmark)doc.GetElements(Element.Type.Bookmark)[0];
        

          '--- Create a bookmark
          Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\sample.doc")
          doc.CreateBookmark("MyBookMark")

          '--- Get an existing bookmark
          Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\sample.doc")
          Dim bmark As Bookmark = doc.GetBookmark("ExistingBookmark")

          '--- Or, if you know the order of the bookmarks in the document
          '--- you can use the following:
          'Dim bmark as Bookmark = doc.GetElements(Element.Type.Bookmark)(0)
        

Name

Description

Name