This documentation is archived and is not being maintained.

Bookmark.MoveStartWhile Method (Object, Object)


Moves the start position of the Bookmark control while 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)

int MoveStartWhile(
	ref object cset,
	ref object count


Type: System.Object

One or more characters. This argument is case sensitive.

Type: System.Object

The maximum number of characters by which the Bookmark control is to be moved. Can be a number or either the F:Microsoft.Office.Interop.Word.WdConstants.wdForward or F:Microsoft.Office.Interop.Word.WdConstants.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 F:Microsoft.Office.Interop.Word.WdConstants.wdForward.

Return Value

Type: System.Int32

The number of characters that the start position of the Bookmark control moved. If no Cset characters are found, the Bookmark control is not changed and the method returns 0 (zero).

While any character in Cset is found, the start position of the Bookmark control is moved.

If the start position is moved forward to a position beyond the original end position, the end position is set to the new start position.

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

The following code example adds a Bookmark control with text to the first paragraph and then moves the range of the bookmark while it can find the characters T, h, i, or s.

This example is for a document-level customization.

private void BookmarkMoveStartWhile()
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
    bookmark1.Text = "This is sample bookmark text.";

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

    bookmark1.MoveStartWhile(ref cSet, ref Count);
Return to top