MoveEndUntil Method Example

This example extends the selection forward in the document until the letter "a" is found. The example then expands the selection by one character to include the letter "a".

With Selection
    .MoveEndUntil Cset:="a", Count:=wdForward
    .MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End With

This example extends the selection forward in the document until a tab is found. If a tab character isn't found in the next 100 characters, the selection isn't moved.

char = Selection.MoveEndUntil(Cset:=vbTab, Count:=100)
If char = 0 Then StatusBar = "Selection not moved"