Solved

Adding multiple words that are incorrectly shown as misspelled to dictionary

Posted on 2004-09-21
5
402 Views
Last Modified: 2006-11-17
When dealing with a body of text with many unrecognised words - which show as incorrectly spelled - is it possible to highlight the whole block, and tell Word to add **any** "misspelled" word to the CUSTOM.DIC?

I typically get this when writing geek documentation (someone's gotta do it!), and am too lazy to go through and add 100 or so more terms individually.  Don't want to add *all* the words, just the ones that Word thinks are misspelled.  Pasting the entire paragraph into CUSTOM.DIC seems a bit brutal!

Selecting a paragraph, right-clicking, and seeing the option "Add ALL to Dictionary" would be the perfect thing...

Some sample text:

Installed services on \\<servername>:
      ACPI - Microsoft ACPI Driver
      AFD - AFD Networking Support Environment
      Alerter - Alerter
      AppMgmt - Application Management
      AsyncMac - RAS Asynchronous Media Driver
      atapi - Standard IDE/ESDI Hard Disk Controller
      Atmarpc - ATM ARP Client Protocol
      audstub - Audio Stub Driver
      awhost32 - pcAnywhere Host Service
      BITS - Background Intelligent Transfer Service
      Browser - Computer Browser
      Cdrom - CD-ROM Driver
      CIMnotify - HP Insight Event Notifier
      cisvc - Indexing Service
0
Comment
Question by:Danny Child
  • 2
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 12119328
This should do it.

Sub AddToDic()
    Dim prError As Range
    Dim Dict As Document
    Dim para As Paragraph
    Dim strErrWords() As String
    Dim iErrWordsCount As Integer
    Dim i As Integer
    Dim bFlag As Boolean
   
    For Each prError In ActiveDocument.SpellingErrors
        ReDim Preserve strErrWords(iErrWordsCount)
        strErrWords(iErrWordsCount) = prError.Text & Chr$(13)
        iErrWordsCount = iErrWordsCount + 1
    Next prError
   
    Application.Options.CheckSpellingAsYouType = False
   
    Set Dict = Documents.Open(CustomDictionaries("CUSTOM.dic").Path & "\" & CustomDictionaries("CUSTOM.dic").Name)
    For i = 0 To iErrWordsCount - 1
    bFlag = False
        For Each para In Dict.Paragraphs
            If strErrWords(i) = para.Range.Text Then
                bFlag = True
                Exit For
            End If
            If UCase$(strErrWords(i)) <= UCase$(para.Range.Text) Then
                para.Range.InsertBefore strErrWords(i)
                bFlag = True
                Exit For
            End If
        Next para
        If Not bFlag Then
            Dict.Paragraphs(Dict.Paragraphs.Count).Range.InsertAfter strErrWords(i)
        End If
    Next i
   
    Dict.Save
    Dict.Close
    Application.Options.CheckSpellingAsYouType = True

End Sub

0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 12127715
It might be easier to open custom.dic and paste that text into it.
Just be sure when you save that you retain the proper name of the file, and that you save it as a text file.
0
 
LVL 23

Author Comment

by:Danny Child
ID: 12133956
The macro seems to work really well, I can see it putting the items into the CUSTOM.DIC folder, but on some larger documents, they are still flagged with the red squiggle.  The only way I've found to get it to go away is to turn off the Tools.. Options.. Spelling & Grammar.. Check Spelling as you Type, and then turn it on again.  

GrahamSkan - any chance of you adding this last piece of functionality?  heck, I'll even double the points!

Regarding Dreamboat's idea, AFAIK, custom.dic only works on having it's entries sorted alphabetically, with a single word per line.  If I was going to do that, it would be quicker to use the right-click.. Add to Dictionary!
0
 
LVL 23

Author Comment

by:Danny Child
ID: 12159848
neat macro, cheers.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12159916
Sorry I haven't yet found a way of forcing the respell check. I think that Word must maintain a cache of the Dictionary, which it refreshes when you click on the Checkbox, but not when it is changed programatically.
I did think of saving, closing and re-opening the document, but that could bring other problems. I also tried removing the Custom.dic from the list of dictionaries and re-adding it, but Word seemed unaware of my actions.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Numbering Only Even Pages - Consecutively -  in Word 2013 3 38
Always hangs on opening 8 68
Regarding Notepad++ 4 37
Excel copy picture into Outlook email 7 47
There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now