Sasa
Sasa

Reputation: 1

C# Select text between caret and end of the document in Word

I'm trying to get the program to select all the text between caret and end of the document in Word. It should be something like:

app.ActiveDocument.Range(Selection, EndOdDocument).Select();

where Selection is supposed to be the caret position, and EndOfDocument - the end of the document. However, after hours of trying, I can't solve this, although the solution is probably something very obvious.

Upvotes: 0

Views: 539

Answers (1)

Slai
Slai

Reputation: 22876

Probably something like:

app.Selection.End = app.ActiveDocument.Content.End;

but, no need to change the selection to get the text:

var doc = app.ActiveDocument;
string text = doc.Range(app.Selection.Start, doc.Content.End).Text;

Upvotes: 0

Related Questions