InsertAfter Method
Collapse the table of content
Expand the table of content

Bookmark.InsertAfter Method (String)

 

Inserts the specified text at the end of a Bookmark control.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

void InsertAfter(
	string Text
)

Parameters

Text
Type: System.String

The text to be inserted.

The following code example adds text and a Bookmark control with text to the document, and then adds comments to the text. Using GoToNext and GoToPrevious, it displays the positions of the comments in a message box.

This example is for a document-level customization.

private void BookmarkGoToNext()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Text = "This is the first paragraph.";
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
       this.Controls.AddBookmark(this.Paragraphs[2].Range,
       "bookmark1");
    bookmark1.Text = "This is original text of the bookmark.";

    object commentText = "This is some comment text.";
    this.Paragraphs[1].Range.Comments.Add(this.Paragraphs[1]
        .Range.Words[4], ref commentText);
    bookmark1.Words.First.Comments.Add(bookmark1.Words.First,
        ref commentText);

    bookmark1.InsertBefore("Text inserted before bookmark. ");
    bookmark1.InsertAfter(" Text inserted after bookmark.");

    Word.Range range1 = bookmark1.GoToNext(Word.WdGoToItem.wdGoToComment);
    Word.Range range2 = bookmark1.GoToPrevious(Word.WdGoToItem.wdGoToComment);

    MessageBox.Show("Using GoToNext, the comment is at position " 
        + range1.Start.ToString() + "\n" +
        "Using GoToPrevious, the comment is at position "
        + range2.Start.ToString());
}
Return to top
Show:
© 2016 Microsoft