Is it possible to get text (line or sentence) from a given line number in MS Word using office automation? I mean its ok if I can get either the text in the given line number or
var word = new Word.Application();
object miss = Missing.Value;
object path = @"D:\viewstate.docx";
object readOnly = true;
var docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss,
ref miss, ref miss, ref miss, ref miss, ref miss,
ref miss, ref miss, ref miss, ref miss, ref miss,
ref miss, ref miss);
string totaltext = "";
object unit = Word.WdUnits.wdLine;
object count = 1;
word.Selection.MoveEnd(ref unit, ref count);
totaltext = word.Selection.Text;
TextBox1.Text = totaltext;
docs.Close(ref miss, ref miss, ref miss);
word.Quit(ref miss, ref miss, ref miss);
docs = null;
word = null;