To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > VBForums CodeBank > CodeBank - Visual Basic 6 and earlier

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Jul 19th, 2005, 06:19 PM   #1
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Arrow Advanced VB/Office Guru™ SpellChecker™

Gangsta Yoda

Description:
I wrote this to demonstrate how to take full advantage of MS Word's built in Spelling and Grammer checker. There
are a few other code examples that show how to do spell checking with Word but they are all using the same technique that
seems to have a few issues like showing the spell dialog behind your app, messing up the line breaks so you need to
apply a code fix to restore them, flashing window, etc.

What makes my spell checker different is that I use the actual spell/grammer checking dialog window and not invoking it by
coding the usual - "Document.CheckSpelling" which seems to cause the mentioned issues.

Since I use the dialog window I preset the type of spelling I wish to perform. Now you can make it dynamic by having a
spell options form in your app to allow the user to preset it to either Ignore words in UPPERCASE, urls, mixed words and
numbers, check grammer, and whether to show spelling suggestions, etc.

Requirements:
Microsoft Word
Versions 8.0 - 11.0 (97 - 2003)


















VB Code:
  1. 'In a module (Module1.bas)
  2. Option Explicit
  3. 'Copyright © 2005 by RobDog888 (VB/Office Guru™). All Rights reserved.
  4. '
  5. 'Distribution: You can freely use this code in your own
  6. '              applications provided that this copyright
  7. '              is left unchanged, but you may not reproduce
  8. '              or publish this code on any web site, online
  9. '              service, or distribute as source on any
  10. '              media without express permission.
  11. '
  12. 'Early binding:
  13. 'Add a reference to MS Word xx.0 Object Library
  14. 'Modifications: none.
  15. 'Late binding:
  16. 'No references needed to any version of Word
  17. 'Modifications: Change object vars definitions (moApp & oDoc) to Object
  18. 'Change constants to their numeric equilivalents.
  19. 'Requirements:
  20. 'MS Word version 97 (8.0) - 2003 (11.0)
  21. Public moApp As Word.Application
  22. Private mbKillMe As Boolean
  23. Public Property Get KillMe() As Boolean
  24.     InitializeMe
  25.     KillMe = mbKillMe
  26. End Property
  27. Public Property Let KillMe(Value As Boolean)
  28.     mbKillMe = Value
  29. End Property
  30. Public Sub InitializeMe()
  31.     On Error Resume Next
  32.     '<INITIALIZE WORD>
  33.     Set moApp = GetObject(, "Word.Application")
  34.     If TypeName(moApp) <> "Nothing" Then
  35.         Set moApp = GetObject(, "Word.Application")
  36.     Else
  37.         Set moApp = CreateObject("Word.Application")
  38.         mbKillMe = True
  39.     End If
  40. End Sub
  41. Public Function SpellMe(ByVal msSpell As String) As String
  42.     On Error GoTo No_Bugs
  43.     Dim oDoc As Word.Document
  44.     Dim iWSE As Integer
  45.     Dim iWGE As Integer
  46.     Dim sReplace As String
  47.     Dim lResp As Long
  48.     If msSpell = vbNullString Then Exit Function
  49.     InitializeMe
  50.     Select Case moApp.Version
  51.         Case "9.0", "10.0", "11.0"
  52.             Set oDoc = moApp.Documents.Add(, , 1, True)
  53.         Case "8.0"
  54.             Set oDoc = moApp.Documents.Add
  55.         Case Else
  56.             MsgBox "Unsupported Version of Word.", vbOKOnly + vbExclamation, "VB/Office Guru™ SpellChecker™"
  57.             Exit Function
  58.     End Select
  59.     Screen.MousePointer = vbHourglass
  60.     App.OleRequestPendingTimeout = 999999
  61.     oDoc.Words.First.InsertBefore msSpell
  62.     iWSE = oDoc.SpellingErrors.Count
  63.     iWGE = oDoc.GrammaticalErrors.Count
  64.     '<CHECK SPELLING AND GRAMMER DIALOG BOX>
  65.     If iWSE > 0 Or iWGE > 0 Then
  66.         '<HIDE MAIN WORD WINDOW>
  67.         moApp.Visible = False
  68.         If (moApp.WindowState = wdWindowStateNormal) Or (moApp.WindowState = wdWindowStateMaximize) Then
  69.             moApp.WindowState = wdWindowStateMinimize
  70.         Else
  71.             moApp.WindowState = wdWindowStateMinimize
  72.         End If
  73.         '</HIDE MAIN WORD WINDOW>
  74.         '<PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
  75.         moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.CheckGrammarWithSpelling = True
  76.         moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.SuggestSpellingCorrections = True
  77.         moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreUppercase = True
  78.         moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreInternetAndFileAddresses = True
  79.         moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreMixedDigits = False
  80.         moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.ShowReadabilityStatistics = False
  81.         '</PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
  82.         '<DO ACTUAL SPELL CHECKING>
  83.         moApp.Visible = True
  84.         moApp.Activate
  85.         lResp = moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Display
  86.         '</DO ACTUAL SPELL CHECKING>
  87.         If lResp < 0 Then
  88.             moApp.Visible = True
  89.             MsgBox "Corrections Being Updated!", vbOKOnly + vbInformation, App.ProductName
  90.             Clipboard.Clear
  91.             oDoc.Select
  92.             oDoc.Range.Copy
  93.             sReplace = Clipboard.GetText(1)
  94.             '<FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
  95.             If (InStrRev(sReplace, Chr(13) & Chr(10))) = (Len(sReplace) - 1) Then
  96.                 sReplace = Mid$(sReplace, 1, Len(sReplace) - 2)
  97.             End If
  98.             '</FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
  99.             SpellMe = sReplace
  100.         ElseIf lResp = 0 Then
  101.             MsgBox "Spelling Corrections Have Been Canceled!", vbOKOnly + vbCritical, "VB/Office Guru™ SpellChecker"
  102.             SpellMe = msSpell
  103.         End If
  104.     Else
  105.         MsgBox "No Spelling Errors Found" & vbNewLine & "Or No Suggestions Available!", vbOKOnly + vbInformation, _
  106.         "VB/Office Guru™ SpellChecker"
  107.         SpellMe = msSpell
  108.     End If
  109.     '</CHECK SPELLING AND GRAMMER DIALOG BOX>
  110.     oDoc.Close False
  111.     Set oDoc = Nothing
  112.     '<HIDE WORD IF THERE ARE NO OTHER INSTANCES>
  113.     If KillMe = True Then
  114.         moApp.Visible = False
  115.     End If
  116.     '</HIDE WORD IF THERE ARE NO OTHER INSTANCES>
  117.     Screen.MousePointer = vbNormal
  118.     Exit Function
  119. No_Bugs:
  120.     If Err.Number = "91" Then
  121.         Resume Next
  122.     ElseIf Err.Number = "462" Then
  123.         MsgBox "Spell Checking Is Temporary Un-Available!" & vbNewLine & "Try Again After Program Re-Start.", _
  124.         vbOKOnly + vbInformation, "ActiveX Server Not Responding"
  125.         Screen.MousePointer = vbNormal
  126.     ElseIf Err.Number = 429 Then
  127.         Set moApp = Nothing
  128.         Resume Next
  129.     Else
  130.         MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbInformation, App.ProductName
  131.         Screen.MousePointer = vbNormal
  132.     End If
  133. End Function
  134. '*********************************************************
  135. 'Example usage:
  136. 'Behind a form (Form1)
  137. '
  138. 'Add a single or multi-line textbox to your form
  139. 'Add a command button (Command1) to invoke the spell checking.
  140. Option Explicit
  141. Private Sub Command1_Click()
  142.     '<SPELL CHECK>
  143.     Text1.Text = SpellMe(Text1.Text)
  144. End Sub
  145. Private Sub Form_Load()
  146.     '<CALL THE SPELLME INITIALIZATION PROCEDURE BEFORE ANY USE>
  147.     InitializeMe
  148. End Sub
  149. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  150.     If KillMe = True Then
  151.         moApp.Quit False
  152.     End If
  153.     Set moApp = Nothing
  154. End Sub
Attached Images
     
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007

Last edited by RobDog888; Jul 21st, 2005 at 02:19 PM. Reason: Spelling error :lol:; Another spelling error :(, Line Break fix; Hide Word Fix
RobDog888 is offline   Reply With Quote
Old Jul 19th, 2005, 08:40 PM   #2
eyeRmonkey
No place like 127.0.0.1
 
eyeRmonkey's Avatar
 
Join Date: Jul 05
Location: Blissful Oblivion
Posts: 2,305
eyeRmonkey has a spectacular aura about (150+)eyeRmonkey has a spectacular aura about (150+)
Re: Advanced VB/Office Guru™ SpellChecker™

Thanks for the code RD!

I seem to be having a problem with Word not closing when the spell check is done. the document is closing but word stays open with a blank MDI type window.

Also, is there a way to make word not show in the taskbar when this is all happening? Its not a big deal, but if there is a simple solution, that would be nice.

Thanks.
__________________
Visual Studio 2005 Professional Edition (.NET Framework 2.0)
~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

~ eyeRmonkey.com
eyeRmonkey is offline   Reply With Quote
Old Jul 19th, 2005, 09:38 PM   #3
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Can you post your code so I can see how its being implemented? Not the module code but your form code.

I can probably come up with a way to hide word in the taskbar. Give me some time to test an idea.

__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 20th, 2005, 03:29 PM   #4
eyeRmonkey
No place like 127.0.0.1
 
eyeRmonkey's Avatar
 
Join Date: Jul 05
Location: Blissful Oblivion
Posts: 2,305
eyeRmonkey has a spectacular aura about (150+)eyeRmonkey has a spectacular aura about (150+)
Re: Advanced VB/Office Guru™ SpellChecker™

I really can't narrow it down to a certain part of the code so I am posting it all in an attachment.
Attached Files
File Type: zip Spell Checker.zip (23.2 KB, 721 views)
__________________
Visual Studio 2005 Professional Edition (.NET Framework 2.0)
~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

~ eyeRmonkey.com
eyeRmonkey is offline   Reply With Quote
Old Jul 20th, 2005, 04:04 PM   #5
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

EM, I updated my example with the fix for a possible extra line break that may or may not be added to the end of the replacement text.

I will look at your code later today. I am leaving for an appointment.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 02:23 PM   #6
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Ok, I made a few updates to the code in my original post. It will now hide the blank Word app between spell check runs if no other
instance of Word is running. If there are then .Close'ing the document will remove it from the taskbar automatically.

There is no easy way to remove Word from the taskbar when it is checking spelling though.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 02:40 PM   #7
dglienna
Banned
 
dglienna's Avatar
 
Join Date: Jun 04
Location: Center of it all
Posts: 17,901
dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)
Re: Advanced VB/Office Guru™ SpellChecker™

Hmmm. It corrected ttest, but it left S instead of A. Then it capitalized the first word in the sentence.

Before

Quote:
this is a test, this is only s ttest
After

Quote:
This is a test, this is only s test
I didn't think Word did that. I'll have t try it.

EDIT: Word does the same thing. Odd.

Great Job. I like Grammar Check!

Last edited by dglienna; Jul 21st, 2005 at 02:44 PM.
dglienna is offline   Reply With Quote
Old Jul 21st, 2005, 02:43 PM   #8
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

How weird! I tested it and it doesnt pickup the s. I tested it also in Word and same results. Hmm...
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 02:47 PM   #9
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

This also doesnt get detected in MS Word.
Quote:
test s is not a workin.
Quote:
Test s is not a working.
I think Bill needs some Grammer lessions.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 03:00 PM   #10
dglienna
Banned
 
dglienna's Avatar
 
Join Date: Jun 04
Location: Center of it all
Posts: 17,901
dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)dglienna is a glorious beacon of light (400+)
Re: Advanced VB/Office Guru™ SpellChecker™

LOL. That was an actual typo, but after proof-reading it to make sure the misspelled word ttest was in there, I decided to leave it. Go Figure!

Have to spread it around some. Got you for a 'Net thread the other day for the Line Numbers. I wondered how you would find line 697, but wasn't about to count them!

Thanks.
dglienna is offline   Reply With Quote
Old Jul 21st, 2005, 03:13 PM   #11
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I was doing a spell check on my verbiage on the original post and I came up with some spelling errors!

Just in case anyone is wondering about what is the ShowReadabilityStatistics then this is what it looks like after the checking is complete.


Ps, Thanks Dave, I'm glad its starting to get some good feedback.

Gangsta Yoda
Attached Images
 
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 06:35 PM   #12
MartinLiss
Administrator
 
MartinLiss's Avatar
 
Join Date: Sep 99
Location: Looking over your shoulder from San Jose, CA
Posts: 29,638
MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Can this be converted to VBScript? I ask because I use the "old" method in a script file to spellcheck posts.
__________________
Tips, Examples & Tutorials:
A valuable forum toolGenerate unique TreeView keysTreeView with "open" and "closed folder" iconsTime code using GetTickCountHow to trap the Tab keyScroll a formNumberBox ActiveX controlColor a ListView rowAn InputBox formHow to use SaveSetting and GetSettingA program registration schemeSpellcheck a TextboxResize controlsOpen Windows Explorer at Last Visited PathA Blackjack GameCount lines of codePrivate Message ViewerCopy/Paste VB CodePaste VB Code Add-InInsert Procedure Names Add-InA calculator for the game of SpiderMy review of REALbasic 2008VB6 Debug TutorialPicture ViewerVBF Photo Contest Winners

Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer.
Marty
If someone helped you today then please consider rating their post.
MartinLiss is offline   Reply With Quote
Old Jul 21st, 2005, 06:38 PM   #13
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I think most of it can be writtne in VB Script but I dont really know it well enough (probably a n00b at it ) to be able
to give you a reliable answer. Isnt VB Script more like this code would be as if it was written using Late Binding?
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 06:46 PM   #14
MartinLiss
Administrator
 
MartinLiss's Avatar
 
Join Date: Sep 99
Location: Looking over your shoulder from San Jose, CA
Posts: 29,638
MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Here is the script file I use.

VB Code:
  1. <!--
  2. +---------------------------------------------------------------------------+
  3.     Function:    Spell Checker
  4.     Description: This script uses Microsoft Word to check the spelling in
  5.                  posts. Word is assumed to be present.
  6. +---------------------------------------------------------------------------+
  7. -->
  8. <SCRIPT LANGUAGE = "VBScript">  
  9.     
  10. Dim objWord
  11. Dim objDoc
  12. Dim objWindow
  13. Dim objSource
  14. Dim objSelect
  15. Dim objSelectRange
  16. Dim strResult
  17. Set objWindow = window.external.menuArguments
  18. Set objSource = objWindow.event.srcElement
  19. Set oDocument = objWindow.document
  20. Set objSelect = oDocument.selection
  21. Set objSelectRange = objSelect.createRange()
  22. 'Create a new instance of word Application
  23. Set objWord = CreateObject("word.Application")
  24. 'new
  25. 'Dim dlg
  26. 'Set dlg = objWord.Dialogs
  27. If objSource.tagName = "TEXTAREA" Then
  28.     select case objWord.version
  29.         'Office 2000
  30.         case "9.0"
  31.             with objWord
  32.                 .WindowState = 2
  33.                 .Visible = True
  34.             end with
  35.             Set objDoc= objWord.Documents.Add( , ,1, True)
  36.         'Office XP
  37.         case "10.0"
  38.             with objWord
  39.                 .windowstate = 2
  40.                 .Visible = False
  41.             end with
  42.             Set objDoc= objWord.Documents.Add( , ,1, True)
  43.             with objWord
  44.                 .windowstate =2
  45.                 .Visible = True
  46.             end with
  47.         'Office 97
  48.         case else ' Office 97
  49.             Set objDoc= objWord.Documents.Add
  50.     end select
  51.         objDoc.Content=objSelectRange.text
  52.         objDoc.CheckSpelling
  53. 'dlg(828).Show(0)
  54.     strResult = left(objDoc.Content, len(objDoc.Content) - 1)
  55.     ' This part may not work if you don't use IE
  56.     If objSelectRange.text = strResult Then
  57.         ' There were no spelling errors, so give the user a
  58.         ' visual signal that something happened
  59.         window.alert("The spelling check is complete.")
  60.     End If
  61.         ' Replace the selected text with the corrected text
  62.     objSelectRange.text = strResult
  63.         'Clean up
  64.         objDoc.Close False
  65.         Set objDoc= Nothing
  66.         objWord.Application.Quit True
  67.         Set objWord= Nothing
  68. end if
  69. </SCRIPT>
__________________
Tips, Examples & Tutorials:
A valuable forum toolGenerate unique TreeView keysTreeView with "open" and "closed folder" iconsTime code using GetTickCountHow to trap the Tab keyScroll a formNumberBox ActiveX controlColor a ListView rowAn InputBox formHow to use SaveSetting and GetSettingA program registration schemeSpellcheck a TextboxResize controlsOpen Windows Explorer at Last Visited PathA Blackjack GameCount lines of codePrivate Message ViewerCopy/Paste VB CodePaste VB Code Add-InInsert Procedure Names Add-InA calculator for the game of SpiderMy review of REALbasic 2008VB6 Debug TutorialPicture ViewerVBF Photo Contest Winners

Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer.
Marty
If someone helped you today then please consider rating their post.
MartinLiss is offline   Reply With Quote
Old Jul 21st, 2005, 06:58 PM   #15
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Is this an addition to that VBF Add-In one of our members made? If not how are you executing it?

Does the Set dlg = objWord.Dialogs work?

The const value for the spellingandgrammER dialog is = 828
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 21st, 2005, 07:05 PM   #16
MartinLiss
Administrator
 
MartinLiss's Avatar
 
Join Date: Sep 99
Location: Looking over your shoulder from San Jose, CA
Posts: 29,638
MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Quote:
Originally Posted by RobDog888
Is this an addition to that VBF Add-In one of our members made? If not how are you executing it?

Does the Set dlg = objWord.Dialogs work?

The const value for the spellingandgrammER dialog is = 828
Yes it all works and yes, it is a part of the "Forum Tool" that I mention in my signature. The code is in an htm file that via Registry entries is appended to the IE right-click context menu.
__________________
Tips, Examples & Tutorials:
A valuable forum toolGenerate unique TreeView keysTreeView with "open" and "closed folder" iconsTime code using GetTickCountHow to trap the Tab keyScroll a formNumberBox ActiveX controlColor a ListView rowAn InputBox formHow to use SaveSetting and GetSettingA program registration schemeSpellcheck a TextboxResize controlsOpen Windows Explorer at Last Visited PathA Blackjack GameCount lines of codePrivate Message ViewerCopy/Paste VB CodePaste VB Code Add-InInsert Procedure Names Add-InA calculator for the game of SpiderMy review of REALbasic 2008VB6 Debug TutorialPicture ViewerVBF Photo Contest Winners

Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer.
Marty
If someone helped you today then please consider rating their post.
MartinLiss is offline   Reply With Quote
Old Jul 22nd, 2005, 12:21 AM   #17
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Martin, instead of checking for a string match between the doc and the string variable you may be able to use words error count
instead and that may help bring the function to other browsers then IE.

VB Code:
  1. oDoc.SpellingErrors.Count ;)
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 22nd, 2005, 12:27 AM   #18
MartinLiss
Administrator
 
MartinLiss's Avatar
 
Join Date: Sep 99
Location: Looking over your shoulder from San Jose, CA
Posts: 29,638
MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)MartinLiss is a name known to all (1000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I'll try it tomorrow.
__________________
Tips, Examples & Tutorials:
A valuable forum toolGenerate unique TreeView keysTreeView with "open" and "closed folder" iconsTime code using GetTickCountHow to trap the Tab keyScroll a formNumberBox ActiveX controlColor a ListView rowAn InputBox formHow to use SaveSetting and GetSettingA program registration schemeSpellcheck a TextboxResize controlsOpen Windows Explorer at Last Visited PathA Blackjack GameCount lines of codePrivate Message ViewerCopy/Paste VB CodePaste VB Code Add-InInsert Procedure Names Add-InA calculator for the game of SpiderMy review of REALbasic 2008VB6 Debug TutorialPicture ViewerVBF Photo Contest Winners

Please go to the Thread Tools menu and click Mark Thread Resolved when you have your answer.
Marty
If someone helped you today then please consider rating their post.
MartinLiss is offline   Reply With Quote
Old Sep 2nd, 2005, 11:46 AM   #19
GaryWilson
New Member
 
Join Date: Sep 05
Posts: 1
GaryWilson is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

I am having one problem. I'm finding that if I happen to have another instance of Word open for another reason it will close it without asking and I will lose my original document. is there any code fix that you can think of that will leave my original word document alone?

-Gary
GaryWilson is offline   Reply With Quote
Old Sep 2nd, 2005, 09:01 PM   #20
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I have been thinking about this for a while and I had tested the code quite well too so I'm not sure yet. How are you implementing it? All in one form or in a module like I have? What version of Word are you running?
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Sep 2nd, 2005, 09:47 PM   #21
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I am running 2003 and I havent been able to replicate Word closing down when a previous document already exists. Can you give more details on how your implementing it?
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Sep 2nd, 2005, 11:35 PM   #22
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I even tried it with multiple separate instances of Word and still didnt close any word windows upon the spellchecker close.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 18th, 2006, 10:13 AM   #23
Oliver1
Addicted Member
 
Join Date: Sep 04
Posts: 254
Oliver1 is an unknown quantity at this point (<10)
Re: [RESOLVED] Spell Checker

Hi, in an Access Module I've copied and pasted the code above. Then in an access form I try the following.

VB Code:
  1. Private Sub Command0_Click()
  2. Me.Text1 = SpellMe(Me.Text1)
  3. End Sub
  4. Private Sub Command3_Click()
  5.     InitializeMe
  6. End Sub
  7. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  8.     If KillMe = True Then
  9.         moApp.Quit False
  10.     End If
  11.     Set moApp = Nothing
  12. End Sub

The module gets called okay but errors out on the
App.OleRequestPendingTimeout = 999999
if I tab this out it then errors out on
Clipboard.Clear

Where does App and clipboard come from eg what refereces do I need, or is this never going to work in Access VBA?
Anyway thanks in advance for any help
Oliver1 is offline   Reply With Quote
Old Jan 18th, 2006, 10:24 AM   #24
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

I moved your post to my CodeBank thread for the VB 6 version of my spellchecker.

In Access there is no QueryUnload event so you need to use the Unload event

VB Code:
  1. Private Sub Form_Unload(Cancel As Integer)
  2. End Sub
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 18th, 2006, 10:29 AM   #25
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

If your using Access only then you dont need any of the code other then using Access' built in spell checking.
VB Code:
  1. Private Sub SpellMe()
  2.     Application.DoCmd.RunCommand acCmdSpelling
  3. End Sub
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 18th, 2006, 10:41 AM   #26
Oliver1
Addicted Member
 
Join Date: Sep 04
Posts: 254
Oliver1 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Sorry, getting confused in my old age, anyway the problem with that is it automatically checks the whole form which I don't want, as the form in question is huge.
Currently I spell check like so.

VB Code:
  1. Public Function Spellcheck(TextStr As String) As String
  2.  
  3.      Set WordApp = CreateObject("Word.Application")
  4.      WordApp.Documents.Add
  5.      Dim wordrange As Word.Range
  6.      Set wordrange = WordApp.ActiveDocument.Range(0, 0)
  7.      wordrange.Text = TextStr
  8.      WordApp.Visible = True
  9.      WordApp.Activate
  10.      wordrange.CheckSpelling , , True
  11.      wordrange.CheckGrammar
  12.      Spellcheck = wordrange.Text
  13.      wordrange.Text = ""
  14.      WordApp.Documents.Close (False)
  15.      WordApp.Quit
  16.      Set WordApp = Nothing
  17. End Function

But this has odd glitches which I was hoping your code would sort out.
Oliver1 is offline   Reply With Quote
Old Jan 18th, 2006, 10:46 AM   #27
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

So your not using VB 6 at all and you dont want to use the built in spell checker? If you just select the textbox or text and the call the SpellMe procedure I just posted it will only check the selection or textbox only.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 18th, 2006, 11:07 AM   #28
Oliver1
Addicted Member
 
Join Date: Sep 04
Posts: 254
Oliver1 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Sorry feel am being relly stupid here. I don't mean to be a pain.
Yes this is fully in access so not vb6 at all.
Anyway have tried using
Application.DoCmd.RunCommand acCmdSpelling
It checks the spelling but then shoots off and spell checks other text boxes.
Which as this database form is used by some very uncomputer literate people I think this will confuse them no end.
Oliver1 is offline   Reply With Quote
Old Jan 18th, 2006, 11:09 AM   #29
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Did you make a selection first?
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 18th, 2006, 11:56 AM   #30
Oliver1
Addicted Member
 
Join Date: Sep 04
Posts: 254
Oliver1 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Not sure what you mean tried higlighting the text and then doing it, but after it checked the highlighted text it moved on to another control.
Oliver1 is offline   Reply With Quote
Old Jan 18th, 2006, 12:27 PM   #31
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

It works in my test form with several textboxes. I highlight 1 and then spellcheck it and it doesnt check the rest of the textboxes.
VB Code:
  1. Option Compare Database
  2. Private Sub SpellMe()
  3.     Me.Text0.SelStart = 0
  4.     Me.Text0.SelLength = Len(Me.Text0.Text)
  5.     Application.DoCmd.RunCommand acCmdSpelling
  6. End Sub
  7. Private Sub Form_Click()
  8.     SpellMe
  9. End Sub
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 18th, 2006, 12:35 PM   #32
Oliver1
Addicted Member
 
Join Date: Sep 04
Posts: 254
Oliver1 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Thanks that works, assume Access doesn't have a grammer checker though.
Oliver1 is offline   Reply With Quote
Old Jan 18th, 2006, 12:39 PM   #33
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

AFAIK, Access does not have a Grammer checker.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 19th, 2006, 04:01 AM   #34
Oliver1
Addicted Member
 
Join Date: Sep 04
Posts: 254
Oliver1 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Thanks for you help.
Oliver1 is offline   Reply With Quote
Old Jan 19th, 2006, 05:32 AM   #35
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Anytime

If you wanted the Grammer checker then you would need to have Word installed and use my original code - post #1.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jan 19th, 2006, 06:17 PM   #36
AReilly
New Member
 
Join Date: Jan 06
Posts: 7
AReilly is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Hi 'Oliver1',
I was just having a read through this thread and was wondering would you mind possibly giving me a sample of where/how you set the acCmdSpelling checks in VBA? ,when you were initially checking all the text boxes on the form?

Would be appreciated if possible,

Thanks
AReilly is offline   Reply With Quote
Old Feb 7th, 2006, 07:14 AM   #37
allen177
New Member
 
Join Date: Feb 06
Location: Cheshire
Posts: 1
allen177 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

I have just implemented this code in my app yesterday and have the following (small) problems. Firstly, when the user clicks to Spellcheck, the dialog box doesn't always come to the top and it makes the app seem as if it is stuck. Secondly, if they have any other Office app running, this app comes to the forefront immediately the button is pressed. My users are running Office 2003 if this is any help.
Thanks
allen177 is offline   Reply With Quote
Old Jul 21st, 2006, 02:23 PM   #38
tony007
Frenzied Member
 
Join Date: Apr 05
Posts: 1,704
tony007 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Quote:
Originally Posted by eyeRmonkey
I really can't narrow it down to a certain part of the code so I am posting it all in an attachment.

man i get this error:


Code:
Compile error:

User-defined type not defined
and pointing at :

WithEvents objSysTray As vbSysTrayTools.SysTray


could u tell me how to fix it i am using visual basic 6.thanks
tony007 is offline   Reply With Quote
Old Jul 21st, 2006, 02:55 PM   #39
RobDog888
Super Moderator
 
RobDog888's Avatar
 
Join Date: Apr 01
Location: LA, Calif. Raiders #1 AKA:Gangsta Yoda™
Posts: 58,667
RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)RobDog888 has a brilliant future (2000+)
Re: Advanced VB/Office Guru™ SpellChecker™

Thats not in my code example but it loks like your missing a class or control in your project.
__________________
VB/Office Guru™ (AKA: Gangsta Yoda®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.

Microsoft MVP 2006, 2007, 2008, 2009, 2010
Office Development FAQ (VBA, VB 6, VB.NET, C#)
Software Engineer MCP (VB 6 & .NET), BSEE, CET (Internet.com's #1 Poster)
If a post has helped you then Please Rate it!
Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista (New)Multiple .NET Framework Versions (New)Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 150 GB HDs RAID 1, 2 GBs DDR2 667 MHz RAM, 3 Viewsonic 17" LCDs, Windows Vista RTM, IE 7, Office 2007
RobDog888 is offline   Reply With Quote
Old Jul 31st, 2006, 05:05 AM   #40
tony007
Frenzied Member
 
Join Date: Apr 05
Posts: 1,704
tony007 is an unknown quantity at this point (<10)
Re: Advanced VB/Office Guru™ SpellChecker™

Quote:
Originally Posted by RobDog888
Thats not in my code example but it loks like your missing a class or control in your project.
Thanks for u reply. Oh i was thinking it was u code but now i tried your code and i get the following error:

Compile error:

User-defined type not defined

and pointing at :

Public moApp As Word.Application


could u help me fix this error. I added one button and a textbox to the project. What else do i need such as refrences or any other controles?

Furthermore, is it possible to underline the spelling mistakes as we type and by clicking on mistake it gives suggestions? Also is it possible to make this program so it only does what i just described on external editboxes ? I be happy if u help me here.Thanks

Last edited by tony007; Jul 31st, 2006 at 05:33 AM.
tony007 is offline   Reply With Quote
Reply

Go Back   VBForums > VBForums CodeBank > CodeBank - Visual Basic 6 and earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:49 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.