Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 6th, 2003, 05:56 AM
pingucain pingucain is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 pingucain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old November 9th, 2003, 07:17 AM
pingucain pingucain is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 pingucain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nobody?

Reply With Quote
  #3  
Old November 9th, 2003, 09:56 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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..

Reply With Quote
  #4  
Old November 9th, 2003, 02:19 PM
pingucain pingucain is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 pingucain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #5  
Old November 10th, 2003, 04:01 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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!..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Macro word to extract words according to dictionary


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway