views:

59

answers:

0

Hello,

I'm trying to set a selection on a textrange from the active TextArea, but it doesn't work. The code below selects the text from the cursorposition, which can be anywhere if the user clicks the textarea, and sets the selection from there to the endposition.

var textRange = (IHTMLTxtRange)_activeHtmlDocument2.selection.createRange();
textRange.collapse(true);
textRange.moveStart("character", startPosition);
textRange.moveEnd("character", endPosition);
textRange.select();

Can anybody help me? Thanks!