|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Macro word to extract words according to dictionary
Hi, I need a macro word to extract words from a text in distinct languages. Looking at google, I found this code, but it doesn´t work with great texts (more than 1000 words).
Now, the code, open another document in which it copy the words that appear in the ms word dictionary. I thought that the solution can be to avoid this second document, and only remove the non dictionary words from the original doc. Please take a look to the code, and tell me if you can help me! Thanks a lot! Sub Macro1() ' 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 = wdSpellingInDictionary 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 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 End Sub |
|
#2
|
|||
|
|||
|
Nobody?
|
|
#3
|
|||
|
|||
|
Too long sorce code!I have read it,but i don't know what you wanna and the code work for.Can u tell me more detail..THx..
|
|
#4
|
|||
|
|||
|
Thx cleverpig.
The idea is open a word doc with a list of words in different languages. It must compare each word with the ms word dictionary selected in that doc. The problem is that code opens another doc and writes the words in that other. I need that the macro delete the word from the inicial doc instead open another in order to save resources. Can you help me? Thx in advance! |
|
#5
|
|||
|
|||
|
Yes,i have known your meaning clearly..But i don't know whole your source code.It's afraided that i couldn't give u a help..Sorry!..
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Macro word to extract words according to dictionary |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|