?
Solved

Can we get the spelling mistake words separately from the word file

Posted on 2012-09-06
10
Medium Priority
?
638 Views
Last Modified: 2012-10-20
Hi All,
Can we get the spelling mistake words separately from the word file

I have 10 word files and each has 80,000+ words

Can anyone hep with a script that can check each file and copy the spell mistake word and if possible the grammar mistake words to a separate file?

Like check where words re in red and green and copy?

thanks
0
Comment
Question by:bsharath
  • 5
  • 5
10 Comments
 
LVL 23

Expert Comment

by:irudyk
ID: 38372171
Try the following code which will first output all of the spelling errors and then all of the grammatical errors for each document.  It assumes that all of the files to check are in the same folder (the path to which you will need to modify in Line 12 of the code.
Sub GetSpellingGrammarErrors()

'if all of the documents are in the same folder
Dim strDocFile As String
Dim strDocPath As String
Dim e As Long
Dim eDoc As Document
Dim cDoc As Document

Set eDoc = Documents.Add(DocumentType:=wdNewBlankDocument)

strDocPath = "C:\Path\"   'enter the path to your file here
strDocFile = Dir(strDocPath & "*.doc*")

While strDocFile <> ""
    
    Set cDoc = Documents.Open(strDocPath & strDocFile)
    If cDoc.SpellingErrors.Count > 0 Or cDoc.GrammaticalErrors.Count > 0 Then
        For e = 1 To cDoc.SpellingErrors.Count
            eDoc.ActiveWindow.Selection.TypeText cDoc.SpellingErrors(e).Text & vbCr
       Next e
        For e = 1 To cDoc.GrammaticalErrors.Count
            eDoc.ActiveWindow.Selection.TypeText cDoc.GrammaticalErrors(e).Text & vbCr
        Next e
    End If
    cDoc.Close wdDoNotSaveChanges
    strDocFile = Dir

Wend

Set cDoc = Nothing
Set eDoc = Nothing

End Sub

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 38375157
Thanks works fine

Can i get 2 files one is spellings and another is grammar issues

Also can it refer a dictionary to skip words that i added?

As the output of 1,20,000 words were 33,000 mistakes

if i can add the dictionary words i have so it can skip them while scanning
0
 
LVL 23

Expert Comment

by:irudyk
ID: 38376613
Okay try the following code for 2 seperate files:
Sub GetSpellingGrammarErrors()

'if all of the documents are in the same folder
Dim strDocFile As String
Dim strDocPath As String
Dim e As Long
Dim eDoc As Document
Dim gDoc As Document
Dim cDoc As Document

Set eDoc = Documents.Add(DocumentType:=wdNewBlankDocument)
Set gDoc = Documents.Add(DocumentType:=wdNewBlankDocument)

strDocPath = "C:\Path\"   'enter the path to your file here
strDocFile = Dir(strDocPath & "*.doc*")

While strDocFile <> ""
    
    Set cDoc = Documents.Open(strDocPath & strDocFile)
    If cDoc.SpellingErrors.Count > 0 Or cDoc.GrammaticalErrors.Count > 0 Then
        For e = 1 To cDoc.SpellingErrors.Count
            eDoc.ActiveWindow.Selection.TypeText cDoc.SpellingErrors(e).Text & vbCr
       Next e
        For e = 1 To cDoc.GrammaticalErrors.Count
            gDoc.ActiveWindow.Selection.TypeText cDoc.GrammaticalErrors(e).Text & vbCr
        Next e
    End If
    cDoc.Close wdDoNotSaveChanges
    strDocFile = Dir

Wend

Set cDoc = Nothing
Set eDoc = Nothing
Set eDoc = Nothing

End Sub

Open in new window


I'm not clear what you are referring to regarding a "dictionary to skip words that I added". I mean if those words are added to the dictionary within Word, they should already be skipped during a spell check.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Author Comment

by:bsharath
ID: 38376994
Thanks
1. Is there a way that we can backup a custom dictionary?

2. How can we add a custom dictionary

As these files are too many

I have few 1,000 words in my excel that i need to add to word dictionary and then give this dictionary to 5+ people who will check these files

So these words are not shows as spelling issues to them?
0
 
LVL 23

Expert Comment

by:irudyk
ID: 38377154
What version of Office are you using?
0
 
LVL 23

Expert Comment

by:irudyk
ID: 38377242
What you can try is the following:
Open your Excel file, select and copy the list of words
Open Notepad and paste the text you copied from Excel
Save the Notepad file as Custom2.DIC
  make sure the file type is set to All types (*.*) otherwise
  the file will be saved as Custon2.DIC.txt
You can distribute the Custom2.DIC file to the other users who can save the file in their My Documents folder.

Now, assuming that you are using Word 2010, you and the other users you sent the Custom2.DIC file to should do the following in order to add the new custom dictionary for Word to reference:
Select File | Options | Proofing
Click the Custom Dictionaries... button
Click the Add... button
Search for and select the Custom2.DIC file and click Open
Click OK

Doing the above should work and prevent those words from being added as spelling errors.
0
 
LVL 11

Author Comment

by:bsharath
ID: 38377686
Can you mention the method for office 2003 or 2007 please...
0
 
LVL 11

Author Comment

by:bsharath
ID: 38377691
Also how can we backup and view the current default dictionary
0
 
LVL 23

Accepted Solution

by:
irudyk earned 2000 total points
ID: 38377742
For how to add a custom dictionary if all versions of Word, see - http://support.microsoft.com/kb/322198

The above link indicates where you can locate the existing/default CUSTOM.DIC file.  You can simply make a copy of that file for backup purposes.  If you open that file using Notepad you will be able to view it contents (i.e. much like how I outlined creating/editing the CUSTOM1.DIC file)
0
 
LVL 11

Author Comment

by:bsharath
ID: 38516786
Sorry to get back on this i get this error

---------------------------
Windows Script Host
---------------------------
Script:      D:\Path\Find spelling and grammar.vbs
Line:      4
Char:      16
Error:      Expected end of statement
Code:      800A0401
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question