none
Spell check using Word COM object RRS feed

  • Question

  • I have built a winform application where I have added a spell check feature using the Word COM object. I have used the code given here

    https://msdn.microsoft.com/en-IN/library/ms173188(v=vs.80).aspx

    Problem:

    When the code reaches last line 

    app.Quit(ref saveChanges, ref originalFormat, ref routeDocument);

    it abruptly open the word (as a flash) and closes it. Can we close the word silently without user getting to know.


    Ankur Chakravarty Hyderabad

    • Moved by CoolDadTx Friday, August 14, 2015 6:24 PM Office related
    Friday, August 14, 2015 5:29 AM

Answers

  • According to your description, I have made a sample then reproduced your issue.

    I suggest that you could modified your codes like below:

    object template = Missing.Value;
    
    object newTemplate = Missing.Value;
    
    object documentType = Missing.Value;
    
    object visible = false;
    
    Word.Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
    

    Monday, August 17, 2015 9:02 AM

All replies

  • According to your description, I have made a sample then reproduced your issue.

    I suggest that you could modified your codes like below:

    object template = Missing.Value;
    
    object newTemplate = Missing.Value;
    
    object documentType = Missing.Value;
    
    object visible = false;
    
    Word.Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
    

    Monday, August 17, 2015 9:02 AM
  • Thanks for the reply.

    Is there a way I can highlight the miss-spelled word on the richtextbox?


    Ankur Chakravarty Hyderabad

    Monday, August 17, 2015 10:30 AM
  • Accroding to your description, you can refer below code:
    private void HighlightText(string errTxt,RichTextBox curRichTextBox)
    {
        int s_start = curRichTextBox.SelectionStart, startIndex = 0, index;
        while ((index = curRichTextBox.Text.IndexOf(errTxt, startIndex)) != -1)
        {
            curRichTextBox.Select(index, errTxt.Length);
            curRichTextBox.SelectionBackColor = Color.Yellow;
            startIndex = index + errTxt.Length;
        }
    
        curRichTextBox.SelectionStart = s_start;
        curRichTextBox.SelectionLength = 0;
        curRichTextBox.SelectionColor = Color.Black;
    }
    

    foreach (Word.Range spellingError in spellErrorsColl)
    {
       HighlightText(spellingError.Text, richTextBox1);
    }

    Otherwise this forum is for discussing about Word Developing, because your issue is about Windows Forms Developing, I suggest that you could post your issue to Windows Forms forum.
    Thank you for your understanding.

    Tuesday, August 18, 2015 8:43 AM