Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

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.

Signature
C#
C#

<p> public sealed class Bookmark : Element
{signature}{signature:Element</p>
} Public
Signature
vb.net
vb.net

<p>Public NotInheritable Class BookmarkBookmark<br />
		Inherits Element
{signature}
{remarks}To insert a bookmark into a document, use [Element</p>
Remarks

To insert a bookmark into a document, use Element.CreateBookmark()

|Element.CreateBookmark(String)]

or

[

Table.CreateBookmarkOnRow()

|Table

.

CreateBookmarkOnRow(Int32, String)].

To

get

a

bookmark

from

an

existing

document

use

the

[

Document.GetBookmark

|Document.GetBookmark(String)]

method.

The

following

sample

shows

you

how

to

add

a

bookmark

to

a

document

and

retrieve

a

bookmark

from

a

document.

{remarks} {example}{code:csharp|title=C#}

Example
Code Block
csharp
csharp
titleC#


          //--- 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];
        
{code} {code:vbnet|title=
Code Block
vbnet
vbnet
titlevb.net
}


          '--- 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)
        
{code} {example} {properties} ||Name||Description|| |[Name|Bookmark.Name]|{excerpt-include:Bookmark.Name|nopanel=true}|
Properties

Name

Description

Name

Excerpt Include
Bookmark.Name
Bookmark.Name
nopaneltrue