Similar question - Position cursor at start/end of Word document
그 대답은 which
과 what
에 대한 자세한 내용이수록. 대답은 일종의 C#과 VB 사이에 매시되었으므로 또 다른 대답을 여기에 포함합니다. 여기서는 문서의 마지막 부분으로 약간 다른 방법을 사용합니다.
내 두 센트 :
//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);
이 방법은, 그것은 마지막 줄에 커서를 이동하는 단어를 말하지 않는 약간 다르지만 마지막 문서의 비율있는 나는 것 1 라인 문서에서 라인의 끝이 될 것입니다. 그러나 커서가 첫 번째 줄 (시작 부분)에 있고 Word에서 마지막 줄로 이동한다고하면 아무 일도 일어나지 않습니다 : 우리는 이미 의으로 시작합니다.
작동하지 않는 것 같습니다. – Rohit