Expand Minimize

Bookmark.Relocate Method

In outline view, moves the paragraphs within the Bookmark control after the next visible paragraph or before the previous visible paragraph.

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

void Relocate(
	int Direction
)

Parameters

Direction
Type: System.Int32

WdRelocate. The direction of the move.

Body text moves with a heading only if the body text is collapsed in outline view or if it is part of the Bookmark control.

The following code example adds text to the first paragraph and then a Bookmark control with text to the second paragraph. The code then relocates the second bookmark to the first paragraph.

This example is for a document-level customization.

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

    this.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView;
    bookmark1.Relocate((int)Word.WdRelocate.wdRelocateUp);
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft