Quick Search for:  in language:    
OLE,code,uses,Automation,allow,open,instance,
   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



 
 
   

Spell Checker (uses MS Word)

Print
Email
 

Submitted on: 5/28/1999
By: T. Heinel 
Level: Not Given
User Rating: By 101 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 8566 times.
 
 
     This code uses OLE Automation to allow VB to open an instance of MS Word if the user has it on their system and spell check the contents of a text box. It could easily be modified to work with any control that has text on it. I would recommend better error control than the On Error statement listed here.
 
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: Spell Checker (uses MS Word)
' Description:This code uses OLE Automat
'     ion to allow VB to open an instance of M
'     S Word if the user has it on their syste
'     m and spell check the contents of a text
'     box. It could easily be modified to work

'     with any control that has text on it. I 
    '     would recommend better error control tha
    '     n the On Error statement listed here.
' By: T. Heinel
'
' Returns:The code automatically replace
'     s the original text of the message box w
'     ith the corrected text.
'
' Assumes:Just create the text box and c
'     ommand button listed in the code.
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=1904&lngWId;=1'for details.'**************************************

Private Sub cmdSpellCheck_Click()

'On Error Resume Next 'Best to un-commen ' t this while testing Dim objMsWord As Word.Application Dim strTemp As String Set objMsWord = CreateObject("Word.Application") objMsWord.WordBasic.FileNew objMsWord.WordBasic.Insert txtMessage.Text objMsWord.WordBasic.ToolsSpelling objMsWord.WordBasic.EditSelectAll objMsWord.WordBasic.SetDocumentVar "MyVar", objMsWord.WordBasic.Selection objMsWord.Visible = False ' Mostly prevents Word from being shown strTemp = objMsWord.WordBasic.GetDocumentVar("MyVar") txtMessage.Text = Left(strTemp, Len(strTemp) - 1) objMsWord.Documents.Close (0) ' Close file without saving objMsWord.Quit ' Exit Word Set objMsWord = Nothing' Clear object memory frmMain.SetFocus' Return focus To Main form End Sub

 
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
5/28/1999 2:17:00 AM:T. Heinel
I forgot to mention that on the VB menu 
you have to press Project / References 
and select Microsoft Word Object 
Library.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/29/1999 6:47:00 PM:Jamie
If you wrote a word processor and you 
decided to sell it and it used MS 
Word's spell checker would that be 
legal?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/29/1999 11:04:00 PM:William M.
You saved my butt!  I've been delaying 
a project
that asked to add a spell 
checker to an application
because I 
wasn't too familiar with how to 
incorporate 
this feature using Word.  
Thanks alot!!
(I tested it and it 
works great!  I made it a 
function
then called it on the 
'lost_focus' event, passing it 
the
text and the form.  The function 
call looks like this:
Text1.text = 
SpellCheck(Tex1.text,Me)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/1999 6:48:00 AM:Ritesh Patel
Excellent! - Works very 
smoothly..
Thanx alot...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/1999 9:16:00 AM:Jenn
I have a quick question. How would I do 
a spell check on a text box with 
MultiLine set to true. The spell 
check works fine but once it fixes a 
misspelled
word, it doesn't keep the 
formatting of the text box. (loses any 
tabs or entering to create a new 
paragraph that you did)
I would 
appreciate any help you can 
give.
Thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/7/1999 3:10:00 PM:Nick B
Very useful code to make into a OCX, 
only problem is Microsoft Word opens 
and shows. Anyone know of how to 
prevent it from showing for that breif 
moment?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/14/1999 9:13:00 PM:Swu
yeah I agree with Nick.  Can I just 
modify any option that hidden the boxes 
open by MS WORD when I execute 
SpellCheck() ?
Thank a lot!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/24/1999 1:43:00 PM:SF
Works greate but I keep losing my text 
in the text box. I am using a richText 
text box.
Thanks SF
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/24/1999 8:44:00 PM:Theothernerd
I hate to be rude, but this same code 
is in the Learning Visual BAsic CD that 
comes with Vb 5 learning edition.  It 
is also much easier to understand for 
those who aren't experts at VB!  So try 
not to compliment him so much.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/26/1999 7:04:00 AM:ccjx
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/18/1999 5:44:00 PM:xjcc
Heh heh heh... I am the evil ccjx from 
another dimension, and you will all 
die! By the way, you ppl are smart, I 
tried using the marquee tag and it 
freaked out on me!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/3/2000 3:00:18 PM:gr33n
Has anyone run into a a problem using 
this with a multi line text box? I'm 
haven't trouble with it. It returns the 
string as one line with return 
characters in it. Anyone have a clue 
how to get it to return in multi line?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/4/2000 6:51:02 AM:Burbble
Hmm it doesn't work. I know why it 
doesn't work... I don't have word! But 
is there some way to make a spell 
checker without word? just make one 
plain from scratch? It would be hard 
putting in all the words, but it would 
be cool. And um, why are you taking the 
code from Microsoft's copyrighted CD 
and saying it's your own...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/4/2000 6:52:53 AM:Rating Guy
Yep this code is from da CD... What 
rating should it get...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/24/2000 5:10:03 AM:Adrian Cantrill
good code, also been delaying a project 
, but i really need this to work on a 
multiline text box without returning 
one long line with no formatting info. 
Anyone any idead
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/26/2000 1:04:14 PM:Prasad
Simple, easy but brilliant code ! 
Thanks for saving our R&D; time !
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/16/2001 6:08:12 PM:Mad Programmer
Could save your sometime by early 
binding.
Dim objMsWord As NEW 
Word.Application
'Then you do not need 
to use CreateObject, Instead use 
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.