none
How to get the grammar and style error list from a word document? RRS feed

  • Question

  • Hi,

    I am trying to get all the grammatical and style error from a word file. as of now I can find the sentences and count of errors in a file. I enabled all the grammatical and style option from proofing option (showing in the Image here) then try to parse the file with following code, by running the script on on the File (https://1drv.ms/w/s!Ah-Jh2Ok5SuHfVUM4dkUGuUfiZc). 

    Word.ProofreadingErrors spellErrorsColl = document.GrammaticalErrors;
    errorCount = spellErrorsColl.Count;
    for (int i=1;i<=errorCount;i++)
    {
    	var a1 = spellErrorsColl[i].GrammaticalErrors;
    	var text = (dynamic)a1.Parent.Text;
    	//string category = ??
    	//string subCategory = ??
    	
    	//string ErrorWord = ??
    
    	Console.WriteLine(text);
    }


    this file contain 2 Errors (Error1 and Error2)

    In the error1, the error type is "Inclusive language" and the sub category is "consider Gender-natural language" and the word is Master

    in the code I want these values like

    string category = "Inclusive language";
    string subCategory = "consider Gender-natural language";

    string errorWord = "Master";

    If I can get the error word then it is a plus to my application but other are mandatory for me.

    same as for 2nd error 

    string category = "Clarity And Conciseness";
    string subCategory = "Consider using a simple word";

    string errorWord = "providing";

    Please help me to find these values.



    Tuesday, April 4, 2017 8:38 AM

All replies

  • Hi Madan Mishra,

    did you try to use ProofreadingErrors.Type Property ?

    if not then please try to test it and let me know whether it meets with your requirements or not.

    this is the only property available for ProofreadingErrors in Word object model.

    you can refer link below.

    ProofreadingErrors.Type Property (Word)

    ProofreadingErrors Object (Word)

    I did not get any other property in object model that can give the category and sub category of error.

    some things in Object model we can't access so if you don't get the category in type property then it is possible that it is not accessible from code.

    Regards

    Deepak 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 5, 2017 2:59 AM
    Moderator
  • Hi Deepak,

    I checked the option ProofreadingErrors.Type, it returns WdProofreadingErrorType. For my case I am getting wdGrammaticalError as I am using document.GrammaticalErrors option. we can conclude it only categorize whether it is grammatical error or Spelling Error.

    I have one doubt manually We can move from one error to another error by pressing F7, Can we implement such event and capture the content? 

     


    Wednesday, April 5, 2017 11:22 AM
  • Hi Madan Mishra,

    I check Document.GrammaticalErrors Property (Word)

    but I in object model I did not get any property or method that can return category of Error.

    so as I mentioned earlier. many things are not accessible.

    you mentioned that you want to add an event and capture content.

    but if there is no any property or method to fetch that category then how will you get that value of category.

    so currently , we can just count it.

    if you think that this property should be accessible through object model then please submit your feedback to user voice.

    Welcome to Word's Suggestion Box!

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 6, 2017 9:26 AM
    Moderator