Condividi tramite


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)

Syntax

'Declaration
Sub Relocate ( _
    Direction As Integer _
)
void Relocate(
    int Direction
)

Parameters

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.

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 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
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);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace