Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();

            //load a document
            document.LoadFromFile(@"..\..\..\..\..\..\Data\FindAndReplace.doc");

            //Find text
            TextSelection[] textSelections = document.FindAllString(this.textBox1.Text, true, true);

            //Set hightlight
            foreach(TextSelection selection in textSelections)
            {
                selection.GetAsOneRange().CharacterFormat.HighlightColor = Color.Yellow;
            }

            //Save doc file.
            document.SaveToFile("Sample.doc", FileFormat.Doc);

            //Launching the MS Word file.
            WordDocViewer("Sample.doc");
        }