Quick Search for:  in language:    
OLE,program,allows,simple,desktop,access,Micr
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,149,602. lines
 Jobs: 144. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
 
PDC 2003: Make the connection
Login



Latest Code Ticker for Visual Basic.
Click here to see a screenshot of this code!HistoryWriter Add-In V.1
By Zvonko Kostovski on 9/3

(Screen Shot)

Click here to see a screenshot of this code!Control Winamp
By Dennis Wollentin on 9/3

(Screen Shot)

Fake Virus Version 1.0
By C.J. Laing on 9/3


][String Encoder
By Andron Smth on 9/3


Font Catalog
By Bill Adams on 9/3


professional search
By Ziad Said on 9/3


Click here to see a screenshot of this code!Drew's Meta Tag Generator
By Drew Phillips on 9/3

(Screen Shot)

Fast BruteForce Class
By §e7eN on 9/3


Click here to see a screenshot of this code!Lotus Domino Exploit Scanner
By §e7eN on 9/3

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Word Magic

Print
Email
 

Submitted on: 6/10/1999
By: Richard Lowe 
Level: Not Given
User Rating: By 6 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 12349 times.
 
 
     This program allows simple desktop access the the Microsoft Word spelling and thesaurus engine using OLE Automation. You can Spell Check, Produce Anangrams, use the Thesaurus and look up the meaning of words. THIS IS A COMPLETE WORKING APPLICATION
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Word Magic
' Description:This program allows simple
'     desktop access the the Microsoft Word sp
'     elling and thesaurus engine using OLE Au
'     tomation.
You can Spell Check, Produce Anangrams, use the Thesaurus and look up the meaning of words. THIS IS A COMPLETE WORKING APPLICATION
' By: Richard Lowe
'
' Assumes:Must have Microsoft Word Insta
'     lled
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=2043&lngWId;=1'for details.'**************************************

'=======================================
'     ====================================
'Start a new project
'add a ComboBox named cboInput
'add a ListBox named lstDisplay
'add a Command Button named cmdHelp capt
'     ion Help
'add a Command Button named cmdExit capt
'     ion Exit
'add 4 Command Buttons (command array) n
'     amed 
'cmdAction(0)	caption Spelling
'cmdAction(1)	caption Wildcard
'cmdAction(2)	caption Anagarm
'cmdAction(3)	Caption Lookup
'In the Project/References menu option t
'     ick the reference for
'Microsoft Word 8.0 Object Library
'=======================================
'     ====================================
'paste the following code
Option Explicit
'=======================================
'     =====================
'== Author : Richard Lowe
'== Date : June 99
'== Contact : riklowe@hotmail.com
'=======================================
'     =====================
'== Desciption
'==
'== This program enable quick and easy d
'     esktop access to
'== the Microsoft Word spelling and thes
'     aurus engine.
'==
'=======================================
'     =====================
'== Version History
'=======================================
'     =====================
'== 1.0 06-Jun-99 RL Initial Release. Sp
'     elling Only
'== 1.1 07-Jun-99 RL Added Widcard, Anag
'     ram and Lookup
'== 1.2 08-Jun-99 RL Added Help 
'=======================================
'     =====================
'---------------------------------------
'     ---------------------
'Define constants
'---------------------------------------
'     ---------------------
Const HeightLimit = 5000
Const WidthLimit = 5640
'---------------------------------------
'     ---------------------
'Dimension variables
'---------------------------------------
'     ---------------------
Dim objMsWord As Word.Application
Dim SugList As SpellingSuggestions
Dim sug As SpellingSuggestion
Dim synInfo As SynonymInfo
Dim synList As Variant
Dim AntList As Variant
Private Sub cmdAction_Click(Index As Integer)

'--------------------------------------- ' --------------------- ' dimension local variables '--------------------------------------- ' --------------------- Dim strTemp As String Dim blnRet As Boolean Dim iCount As Integer '--------------------------------------- ' --------------------- ' Asign an error handler '--------------------------------------- ' --------------------- On Error Goto eh_Trap: '--------------------------------------- ' --------------------- ' If cboInput has changed, add it as an ' entry to the list '--------------------------------------- ' --------------------- If cboInput.List(0) <> cboInput Then cboInput.AddItem cboInput, 0 End If
'--------------------------------------- ' --------------------- 'Assign the objMsWord object reference t ' o the Word application '--------------------------------------- ' --------------------- Set objMsWord = New Word.Application '--------------------------------------- ' --------------------- 'Due to a bug, you have to open a file t ' o use GetSpellingSuggestions 'This is documented in Q169545 on micros ' oft knowledge base '--------------------------------------- ' --------------------- objMsWord.WordBasic.FileNew'open a doc objMsWord.Visible = False'hide the doc '--------------------------------------- ' --------------------- ' clear display area '--------------------------------------- ' --------------------- lstDisplay.Clear '--------------------------------------- ' --------------------- ' select which button has been pressed '--------------------------------------- ' --------------------- Select Case Index Case 0 '--------------------------------------- ' --------------------- 'Spelling '--------------------------------------- ' --------------------- blnRet = objMsWord.CheckSpelling(cboInput) '--------------------------------------- ' --------------------- 'if incorrectly spelt, check for suggest ' ions. Iterate and display '--------------------------------------- ' --------------------- If blnRet = True Then lstDisplay.AddItem "OK" Else Set SugList = objMsWord.GetSpellingSuggestions(cboInput, _ SuggestionMode:=wdSpelling) If SugList.Count = 0 Then lstDisplay.AddItem "No suggestions" Else For Each sug In SugList lstDisplay.AddItem sug.Name Next sug
End If
End If
Case 1 '--------------------------------------- ' --------------------- 'WildCard '--------------------------------------- ' --------------------- Set SugList = objMsWord.Application.GetSpellingSuggestions(cboInput, _ SuggestionMode:=wdWildcard) '--------------------------------------- ' --------------------- 'If entries found, Iterate and display '--------------------------------------- ' --------------------- If SugList.Count = 0 Then lstDisplay.AddItem "No suggestions" Else For Each sug In SugList lstDisplay.AddItem sug.Name Next sug
End If
Case 2 '--------------------------------------- ' --------------------- 'Anagram '--------------------------------------- ' --------------------- Set SugList = objMsWord.GetSpellingSuggestions(cboInput, _ SuggestionMode:=wdAnagram) '--------------------------------------- ' --------------------- 'If entries found, Iterate and display '--------------------------------------- ' --------------------- If SugList.Count = 0 Then lstDisplay.AddItem "No suggestions" Else For Each sug In SugList lstDisplay.AddItem sug.Name Next sug
End If
Case 3 '--------------------------------------- ' --------------------- 'Lookup '--------------------------------------- ' --------------------- '--------------------------------------- ' --------------------- 'Assign the synInfo object reference to ' the Word Synonym Information '--------------------------------------- ' --------------------- Set synInfo = objMsWord.SynonymInfo(cboInput) lstDisplay.AddItem "--- MEANING ---" '--------------------------------------- ' --------------------- 'If entries found, Iterate and display '--------------------------------------- ' --------------------- If synInfo.MeaningCount >= 2 Then synList = synInfo.MeaningList For iCount = 1 To UBound(synList) lstDisplay.AddItem synList(iCount) Next iCount
Else lstDisplay.AddItem "None" End If
lstDisplay.AddItem "--- SYNONYM ---" '--------------------------------------- ' --------------------- 'If entries found, Iterate and display '--------------------------------------- ' --------------------- If synInfo.MeaningCount >= 2 Then synList = synInfo.SynonymList(2) For iCount = 1 To UBound(synList) lstDisplay.AddItem synList(iCount) Next iCount
Else lstDisplay.AddItem "None" End If
Set synInfo = Nothing End Select
'--------------------------------------- ' --------------------- 'Clean exit point '--------------------------------------- ' --------------------- eh_exit: objMsWord.Quit Set objMsWord = Nothing cboInput.SetFocus Exit Sub '--------------------------------------- ' --------------------- 'Error Handler '--------------------------------------- ' --------------------- eh_Trap: lstDisplay.AddItem Err & vbTab & Error$ Resume eh_exit: End Sub
Private Sub cmdExit_Click()
Unload Me End Sub
Private Sub cmdHelp_Click()
'--------------------------------------- ' --------------------- 'Display help information in the viewing ' area '--------------------------------------- ' --------------------- lstDisplay.Clear lstDisplay.AddItem "Spelling " lstDisplay.AddItem "Enter a word into the box above, press 'Spelling'" lstDisplay.AddItem "Correctly spelt words will display 'OK'" lstDisplay.AddItem "Incorrectly spelt words will display a list of " lstDisplay.AddItem "choices that most closely match the word" lstDisplay.AddItem " " lstDisplay.AddItem "Wildcard " lstDisplay.AddItem "Enter a word into the box above, press 'Wildcard'" lstDisplay.AddItem "Use a ? To indicate an unkown letter" lstDisplay.AddItem "Use a * To indicate muliple unkown letters" lstDisplay.AddItem "Examples (?) - Cl?se, Un?no?n " lstDisplay.AddItem "Examples (*) - Cl*, C*e" lstDisplay.AddItem " " lstDisplay.AddItem "Anangram " lstDisplay.AddItem "Enter a word into the box above, press 'Anagram'" lstDisplay.AddItem "The program will find all words in the " lstDisplay.AddItem "dictionary containing those letters " lstDisplay.AddItem " " lstDisplay.AddItem "Lookup " lstDisplay.AddItem "Enter a word into the box above, press 'Lookup'" lstDisplay.AddItem "The program will find the meaning and synonym " lstDisplay.AddItem "for the word from the dictionary " lstDisplay.AddItem " " lstDisplay.AddItem "General " lstDisplay.AddItem "Double click On an entry In this list box" lstDisplay.AddItem "and it will be transfered To the box above." lstDisplay.AddItem "Use the up and down arrows On the keyboard " lstDisplay.AddItem "or Select the arrow at the right hand side " lstDisplay.AddItem "of the above box, To scroll through all of " lstDisplay.AddItem "the word you have entered." lstDisplay.AddItem "" lstDisplay.AddItem "Please e-mail any comments / suggestions to" lstDisplay.AddItem "me - It's great To Get feedback." lstDisplay.AddItem "My e-mail address is riklowe@hotmail.com" lstDisplay.AddItem "" End Sub
Private Sub Form_Load()
cboInput.Clear End Sub
Private Sub Form_Resize()
'--------------------------------------- ' --------------------- 'Do not let the screen size get to small ' , so that the button 'are always visible '--------------------------------------- ' --------------------- Select Case Me.WindowState Case vbNormal If Me.Height < HeightLimit Then Me.Height = HeightLimit End If
lstDisplay.Height = Me.Height - 1000 Me.Width = WidthLimit Case Else End Select
End Sub
Private Sub lstDisplay_DblClick()
'--------------------------------------- ' --------------------- 'Move entry from listbox into combo box '--------------------------------------- ' --------------------- cboInput.AddItem lstDisplay, 0 cboInput.ListIndex = 0 lstDisplay.Clear cboInput.SetFocus End Sub


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
6/10/1999 10:22:00 AM:DMan
Best Spellchecker I seen on this site - 
great code - the way it should be done
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/2/1999 9:24:00 PM:Vbmaster
Yes, making applications that needs M$ 
Word to be installed on the system, 
that's just GREAT!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/6/1999 11:13:00 AM:Pauline
hello there..... it's really great to 
have all these source code made 
available... i have just view the word 
magic program and its really great...  
there is one thing that i might need to 
ask your favour from... im currently is 
still studying and so im using VB to 
develop my application for my project.. 
i am having difficulties in one of the 
prgram that im doing that is e-mail and 
FTP... i was just wondering if u could 
help me out here as i am stuck half 
way... is there any available source 
code for mail, chatting as well as 
FTP..
i really appreciate it if u 
could reply me back...
thank 
you...
sorry for all the trouble that 
i might have caused....:)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/7/1999 1:10:00 PM:jd
Hey, I don't have Microsoft Word 8.0 
Object Library, please send it to me or 
send me the project thanks.
    -jd
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/10/1999 10:11:00 AM:Robert Sanders
Wow, this is really cool.  It's almost 
exactly what I've been looking for.  
Most other demo's use word's popup 
spell checking box.
Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/22/1999 10:35:00 PM:Sheepy
Its gonna take me ages to work out how 
this works!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/4/1999 12:44:00 PM:Sulayman Khan
I think your program is great... 
however i have problem when i run it. 
You see, when the program loads the 
dictionary from word... my program 
crashes. What should I do?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/29/1999 5:01:00 AM:Micha
Nice code, works like a 
charm.
However, it would be more 
useful if
you can check the text from 
a textbox
in stead of a combo/listbox. 
I've tried to do it myself, but to 
no
avail. Can you (or anyone else) 
tell
me how? Thnx.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/3/2000 3:14:00 PM:gr33n
I can't seem to get this to work... 
Could it be that I am running WinNT?
I 
keep getting an error on this line "Dim 
objMsWord As Word.Application" work 
isn't an option in my VB6.0
Anyone 
have a clue how to fix it or is it a 
problem with WinNT.. I didn't install 
word first.. Could that be the problem??
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/6/2000 10:39:49 PM:pantana
Nice.  I noticed that if your using the 
MS Word 9.0 Object library, the anagram 
and wildcard don't work.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/6/2000 10:41:25 PM:pantana
Also, I was wondering, where do you 
find all the info on the parameters for 
various MS dll's.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/8/2000 5:17:47 PM:APERSON
Is what you need to do, is make a spell 
checker for people that don't have MS 
Word, I do but I have beeen trying to 
make one for my friend cause he 
doesn't. I don't like your code because 
of useing ms word
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/9/2000 3:37:43 AM:Richard Lowe
APERSON - If you don't like my code - 
then don't use it !!!! Just because you 
have a problem with Microsoft dosn't 
mean everyone else does. Who do you 
think wrote Visual Basic.
GROW UP 
and get a grammer checker while your at 
it - I think MS Word has one you could 
use !!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/29/2000 3:51:13 AM:Yang Zeqi
You really saved my day! Keep up the 
good work man!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/2/2000 3:50:28 PM:Dave
A delightful expose' (as it were) of 
Word automation!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/29/2000 11:13:50 PM:Troy J
I am running WinNT 4, SP6a, Word2k, 
same problem as the above guy using 
WinNT.
Error "User Defined Type Not 
Defined" on this line:
Dim objMsWord 
As Word.Application
I do have the 
reference set, etc...  Anyone have any 
ideas?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/28/2002 1:06:51 PM:David
ATTN: Richard Lowe
I think your 
script would be great - If I could run 
it -.
Do you have any solution for 
Word XP users?  I can't seem to find 
Word in the reference box.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/8/2002 7:34:54 PM:~ : . Jeff ''Capes'' . : ~
only the spell check does work with 
object lib. 9.0 
Unless: 5 from me!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/14/2002 7:36:44 PM:Danny J.
Can someone make this really easy?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/11/2003 8:32:35 PM:
Great code ! 5 stars
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.