다음을 통해 공유


Bookmark.EndOf Method

Moves or extends the ending character position of a Bookmark control to the end of the nearest text unit.

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

Syntax

'Declaration
Function EndOf ( _
    ByRef unit As Object, _
    ByRef extend As Object _
) As Integer
int EndOf(
    ref Object unit,
    ref Object extend
)

Parameters

Return Value

Type: System.Int32
The number of character positions the Bookmark was extended.

Remarks

If both the starting and ending positions for the Bookmark control are already at the end of the unit, this method does not move or extend the Bookmark control.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Examples

The following code example adds a Bookmark control with text to the document and then adds additional text after the bookmark. It then extends the bookmark by one word.

This example is for a document-level customization.

Private Sub BookmarkEndOf()
    Dim Unit As Object = Word.WdUnits.wdWord
    Dim Extend As Object = Word.WdMovementType.wdMove
    Me.Paragraphs(1).Range.InsertParagraphBefore()

    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "This is sample bookmark text."
    Bookmark1.InsertAfter(" This text is inserted after the bookmark.")
    Bookmark1.EndOf(Unit, Extend)

End Sub
private void BookmarkEndOf()
{
    object Unit = Word.WdUnits.wdWord;
    object Extend = Word.WdMovementType.wdMove;
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text. ";
    bookmark1.InsertAfter("This text is inserted after the bookmark.");
    bookmark1.EndOf(ref Unit, ref Extend);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace