Similar question - Position cursor at start/end of Word document
That answer goes into more detail about the which
and the what
. The answers are kind of mashed up between c# and vb so I include yet another answer here, that uses a slightly different method of going to the last part of the document.
My two cents:
//vb does this kind of thing for them
//but in c# we need an object we can pretend is null
object oMissing = System.Reflection.Missing.Value;
//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc; //whenever i read this i think 'hodor'
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
object StartPos = 0;
object Endpos = 1;
Microsoft.Office.Interop.Word.Range rng = oDoc.Range(ref StartPos, ref Endpos);
rng.Text = "This is first line Word from C#";
//object what = Word.WdGoToItem.wdGoToLine;
//I couldn't get wdGoToLine to work but wdGoToPercent was happy
object what = Word.WdGoToItem.wdGoToPercent;
object which = Word.WdGoToDirection.wdGoToLast;
oWord.Selection.GoTo(ref what, ref which, oMissing, oMissing);
This method is slightly different in that it doesn't tell word to move the cursor to the last line, but the last percentage of the document, which I will have to assume is 100. That would be the end of the line in a one-line document, but if the cursor is on the first line (at the beginning) and we tell Word to goto the last line, nothing happens: we are already there, at the beginning of the last line.