i have done it in my way
counting the characters seems to me very important
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Word = Microsoft.Office.Interop.Word;
namespace EstemaraA4Shmrani
{
public partial class Form1 : Form
{
Word.Application wrdApp;
Word._Document wrdDoc;
Word.Range rng;
Object oMissing = System.Reflection.Missing.Value;
Word.Bookmark bookmarkA;
Object name;
Object unit, count, extend;
Object start, end;
Word.Selection wrdSelection;
public Form1()
{
InitializeComponent();
}
private void CallWord_Click(object sender, EventArgs e)
{
wrdApp = new Word.Application();
wrdApp.Visible = true;
Object range = rng;
name = "D:\\EstemaraA4Sabtan.docx";
wrdDoc = wrdApp.Documents.Open(ref name, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing);
InsertTextAtSelection("Hellow 0\n");
InsertTextAtSelection("Hellow 1\n");
InsertTextAtSelection("Hellow 2\n");
wrdDoc.ActiveWindow.View.ShowBookmarks = true;
MoveUpNLine(2); InsertTextAtSelection("Hellow A bookmarkA\n");
MoveNcharacterLeft(9);
start = 9 * 2 ;
end = 9 * 3 ;
rng = wrdDoc.Range(ref start, ref end);
rng.Select();
range = rng;
bookmarkA = wrdDoc.Bookmarks.Add("This_is_the_name_of_bookmark_in_ms_word", ref range);
rng.InsertAfter(" after ");
wrdSelection = null;
wrdDoc = null;
wrdApp = null;
}
private void MoveUpNLine(Object id)
{
unit = Word.WdUnits.wdLine;
extend = Word.WdMovementType.wdMove;
wrdApp.Selection.MoveUp(ref unit, ref id, ref extend);
}
private void MoveDownNLine(Object id)
{
unit = Word.WdUnits.wdLine;
extend = Word.WdMovementType.wdMove;
wrdApp.Selection.MoveDown(ref unit, ref id, ref extend);
}
private void MoveNcharacterLeft(Object n)
{
unit = Word.WdUnits.wdCharacter;
count = n;
extend = Word.WdMovementType.wdMove;
wrdApp.Selection.MoveLeft(ref unit, ref count,
ref extend);
}
private void MoveNcharacterRight(Object n)
{
unit = Word.WdUnits.wdCharacter;
count = n;
extend = Word.WdMovementType.wdMove;
wrdApp.Selection.MoveRight(ref unit, ref count,
ref extend);
}
private void InsertTextAtSelection(string Mystring)
{
Word.Selection sln = wrdApp.Selection;
wrdApp.Options.Overtype = false;
sln.TypeText(Mystring);
}
private void SelectSentencesId(int id)
{
if (wrdDoc.Sentences.Count >= id)
{
start = wrdDoc.Sentences[id+1].Start;
end = wrdDoc.Sentences[id+1].End;
rng = wrdDoc.Range(ref start, ref end);
rng.Select();
}
}
private void SelectN_Words(Object n)
{
unit = Word.WdUnits.wdWord;
count = n;
extend = Word.WdMovementType.wdExtend;
wrdApp.Selection.MoveRight(ref unit,ref count,ref extend);
}
}
}