These macros works in MS Word 97 Once you have installed the macro below, you will need to add a macro button in your toolbar or in your right-click menu to run the macro.
Macro for extracting words from a document that are not present in MS Word's spell-check dictionaryWhat the macro doesThis macro can be useful for terminology work (working with the source language document). It goes through your document, word by word, checking the spelling of the individual words. If a word is not found in Microsoft Word's spell-check dictionary, it is copied to a new file. The process may take a while for long texts, but at the end you will be presented with a list of all the words in your document that were not present in the spell-check dictionary, with any duplicates removed. How to set up the macro1. Select and copy the text of the macro shown below: Copy only the material that appears between the lines of asterisks; DO NOT copy extra blank lines or the asterisks themselves. **********cut here (do not include this line) ********** ' ExtractNewWords Macro: Extracts words from your document' that are not present in MS Word's spell-check dictionary ' Useful for terminology research ' Macro recorded on 14.08.02 by Tanya Harvey ' ' If no Word document is open On Error GoTo MainStop If Documents.Count = 0 Then WordBasic.MsgBox "Open the document from which you wish to extract the words that are not present in MS Word's spell-check dictionary!" Exit Sub End If ' If more than one Word document is open If Documents.Count > 1 Then WordBasic.MsgBox "Close all Word documents and open only the document from which you wish to extract the words that are not present in MS Word's spell-check dictionary!" Exit Sub End If ' Declaration in confirmation dialogue box Dim Prompt As String Dim Title As String Dim Response As String Dim Style As Integer Dim lingo As String lingo = ActiveDocument.AttachedTemplate.LanguageID For Each la In Languages x = Application.Languages(la).ID If x = lingo Then lingo = la.NameLocal End If Next la Prompt = "Is the language of your document <" + lingo$ + ">?" + Chr(13) + "(If not, click <No> and set the correct language!)" + Chr(13) + "" + Chr(13) + "This operation may take a while..." Style = 36 Title = "Document language setting" Response = MsgBox(Prompt, Style, Title) If Response = vbNo Then MsgBox "To set the language of your document, select:" + Chr(13) + "" + Chr(13) + "Edit/Select All" + Chr(13) + "Tools/Language/Set Language (select your language)" + Chr(13) + "Default/Yes/OK" Exit Sub Else ' Open a new document in which to save the words Set doct = Documents.Add ' Arrange open windows Windows.Arrange ' Activate the document from which to extract the terminology Dim AnzahlFenster As Integer Dim NummerAktivesFenster As Integer AnzahlFenster = Application.Windows.Count NummerAktivesFenster = Application.ActiveWindow.Index If AnzahlFenster > NummerAktivesFenster Then Application.ActiveWindow.Next.Activate Else Application.Windows(1).Activate End If ' Select the entire content of the document Selection.WholeStory ' For each word in the document do all instructions up to "Next" For Each mot In Selection.Words ' If the word is not present in MS Word's spell-check dictionary If mot.GetSpellingSuggestions.SpellingErrorType = wdSpellingNotInDictionary Then ' Activate the document listing the words extracted doct.Activate ' Remove any additional spaces after the word mot = Trim(mot) ' Type the word in the list Selection.TypeText mot ' followed by a paragraph mark Selection.TypeParagraph End If Next ' Go to top of list of words extracted Selection.HomeKey Unit:=wdStory ' Tidy the list by removing duplicates Do ' Copy the next word Selection.EndKey Unit:=wdLine, Extend:=wdExtend Selection.Copy Dim A$ ' Call highlighted word a$ A$ = WordBasic.[Selection$]() ' Deselect current term so that it is not replaced and at least one occurrence remains Selection.EndKey Unit:=wdLine ' Replace all duplicates with no text Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = A$ .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll ' Deselect previous word to continue with next Selection.MoveRight Unit:=wdCharacter, Count:=1 ' Repeat until end of document Loop While WordBasic.AtEndOfDocument() = 0 WordBasic.MsgBox "End of spell check: All the words not present in MS Word's spell-check dictionary have been written to a separate file. Duplicates have been removed." End If MainStop: If Err.Number <> 0 Then MsgBox "An error has occurred. Make sure that the dictionary for the language of your document is installed (search your hard drive for <*.lex> to locate the dictionary files.)" End If **********cut here (do not include this line) ********** 2. In the menu bar at the top of your window in Word, click on the Tools menu. Click on Macro, then on Macros in the sub-menu. 3. The Macros dialog box will open. Type the name "ExtractNewWords" for the macro in the "Macro name:" field. 4. Click the Create button. 5. A window titled "Microsoft Visual Basic Normal [New Macros (Code)]" will open. In the window that appears, find the line of text that reads: Macro created [Todays Date] by [Your Name] 6. Paste the macro lines that you copied in Step 1 into the Visual Basic window, at the spot where the input cursor is blinking. 7. Save your macro by clicking the Save button (diskette icon) on the toolbar. 8. Close the whole Visual Basic window. Your macro is now installed. 9. Add a macro button in your toolbar or in your right-click menu to run the macro.
How to run the macroBefore launching this macro, you will need to specify the language of your document:
Open only the document from which you wish to extract the words that are not present in MS Word's spell-check dictionary, then click on the macro button in your toolbar or select the macro from your right-click menu.
|
Back / Tools for Translators / Home / Site Map
http://www.multilingual.ch
Web design by Tanya Harvey Ciampi