Share via


Bookmark.Relocate(Int32) Method

Definition

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

public:
 void Relocate(int Direction);
public void Relocate (int Direction);
abstract member Relocate : int -> unit
Public Sub Relocate (Direction As Integer)

Parameters

Direction
Int32

WdRelocate. The direction of the move.

Examples

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);
}
Private Sub BookmarkRelocate()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "This is sample text. "

    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(2).Range, "Bookmark1")
    Bookmark1.Text = "This is the text of the bookmark."

    Me.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView
    Bookmark1.Relocate(Word.WdRelocate.wdRelocateUp)
End Sub

Remarks

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.

Applies to