Partilhar via


Bookmark.MoveEndUntil Method

Moves the end position of the Bookmark control until any of the specified characters are found in the document.

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

Syntax

'Declaration
Function MoveEndUntil ( _
    ByRef cset As Object, _
    ByRef count As Object _
) As Integer
int MoveEndUntil(
    ref Object cset,
    ref Object count
)

Parameters

  • cset
    Type: System.Object%

    One or more characters. This argument is case sensitive.

  • count
    Type: System.Object%

    The maximum number of characters by which the Bookmark control is to be moved. Can be a number or either the wdForward or wdBackward constant. If Count is a positive number, the Bookmark control is moved forward in the document. If it is a negative number, the Bookmark control is moved backward. The default value is wdForward.

Return Value

Type: System.Int32
The number of characters by which the end position of the Bookmark control was moved. If Count is greater than 0 (zero), this method returns the number of characters moved plus 1. If Count is less than 0 (zero), this method returns the number of characters moved minus 1. If no Cset characters are found, the Bookmark control is not changed and the method returns 0 (zero).

Remarks

If the movement is forward in the document, the Bookmark control is expanded.

If the end position is moved backward to a point that precedes the original start position, the start position is set to the new ending position.

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 first paragraph and then adds another Bookmark control to the third word in the first bookmark. The code then moves the range of the second bookmark until it finds the character k.

This example is for a document-level customization.

Private Sub BookmarkMoveEndUntil()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "This is sample bookmark text." 

    Dim Bookmark2 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Bookmark1.Words(3), "Bookmark2")

    Bookmark2.MoveEndUntil("k", Bookmark1.Characters.Count)
End Sub
private void BookmarkMoveEndUntil()
{
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";

    Microsoft.Office.Tools.Word.Bookmark bookmark2 =
        this.Controls.AddBookmark(bookmark1.Words[3],
        "bookmark2");

    object Count = bookmark1.Characters.Count;
    object cSet = "k";

    bookmark2.MoveEndUntil(ref cSet, ref Count);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace