Jul 19th, 2005, 05:19 PM
#1
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:
'In a module (Module1.bas)
Option Explicit
'Copyright © 2005 by RobDog888 (VB/Office Guru™). All Rights reserved.
'
'Distribution: You can freely use this code in your own
' applications provided that this copyright
' is left unchanged, but you may not reproduce
' or publish this code on any web site, online
' service, or distribute as source on any
' media without express permission.
'
'Early binding:
'Add a reference to MS Word xx.0 Object Library
'Modifications: none.
'Late binding:
'No references needed to any version of Word
'Modifications: Change object vars definitions (moApp & oDoc) to Object
'Change constants to their numeric equilivalents.
'Requirements:
'MS Word version 97 (8.0) - 2003 (11.0)
Public moApp As Word.Application
Private mbKillMe As Boolean
Public Property Get KillMe() As Boolean
InitializeMe
KillMe = mbKillMe
End Property
Public Property Let KillMe(Value As Boolean)
mbKillMe = Value
End Property
Public Sub InitializeMe()
On Error Resume Next
'<INITIALIZE WORD>
Set moApp = GetObject(, "Word.Application")
If TypeName(moApp) <> "Nothing" Then
Set moApp = GetObject(, "Word.Application")
Else
Set moApp = CreateObject("Word.Application")
mbKillMe = True
End If
End Sub
Public Function SpellMe(ByVal msSpell As String) As String
On Error GoTo No_Bugs
Dim oDoc As Word.Document
Dim iWSE As Integer
Dim iWGE As Integer
Dim sReplace As String
Dim lResp As Long
If msSpell = vbNullString Then Exit Function
InitializeMe
Select Case moApp.Version
Case "9.0", "10.0", "11.0"
Set oDoc = moApp.Documents.Add(, , 1, True)
Case "8.0"
Set oDoc = moApp.Documents.Add
Case Else
MsgBox "Unsupported Version of Word.", vbOKOnly + vbExclamation, "VB/Office Guru™ SpellChecker™"
Exit Function
End Select
Screen.MousePointer = vbHourglass
App.OleRequestPendingTimeout = 999999
oDoc.Words.First.InsertBefore msSpell
iWSE = oDoc.SpellingErrors.Count
iWGE = oDoc.GrammaticalErrors.Count
'<CHECK SPELLING AND GRAMMER DIALOG BOX>
If iWSE > 0 Or iWGE > 0 Then
'<HIDE MAIN WORD WINDOW>
moApp.Visible = False
If (moApp.WindowState = wdWindowStateNormal) Or (moApp.WindowState = wdWindowStateMaximize) Then
moApp.WindowState = wdWindowStateMinimize
Else
moApp.WindowState = wdWindowStateMinimize
End If
'</HIDE MAIN WORD WINDOW>
'<PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.CheckGrammarWithSpelling = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.SuggestSpellingCorrections = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreUppercase = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreInternetAndFileAddresses = True
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.IgnoreMixedDigits = False
moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Application.Options.ShowReadabilityStatistics = False
'</PREP CHECK SPELLING OPTIONS DIALOG BOX (MODIFY TO YOUR PREFERENCES)>
'<DO ACTUAL SPELL CHECKING>
moApp.Visible = True
moApp.Activate
lResp = moApp.Dialogs(wdDialogToolsSpellingAndGrammar).Display
'</DO ACTUAL SPELL CHECKING>
If lResp < 0 Then
moApp.Visible = True
MsgBox "Corrections Being Updated!", vbOKOnly + vbInformation, App.ProductName
Clipboard.Clear
oDoc.Select
oDoc.Range.Copy
sReplace = Clipboard.GetText(1)
'<FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
If (InStrRev(sReplace, Chr(13) & Chr(10))) = (Len(sReplace) - 1) Then
sReplace = Mid$(sReplace, 1, Len(sReplace) - 2)
End If
'</FIX FOR POSSIBLE EXTRA LINE BREAK AT END OF TEXT>
SpellMe = sReplace
ElseIf lResp = 0 Then
MsgBox "Spelling Corrections Have Been Canceled!", vbOKOnly + vbCritical, "VB/Office Guru™ SpellChecker"
SpellMe = msSpell
End If
Else
MsgBox "No Spelling Errors Found" & vbNewLine & "Or No Suggestions Available!", vbOKOnly + vbInformation, _
"VB/Office Guru™ SpellChecker"
SpellMe = msSpell
End If
'</CHECK SPELLING AND GRAMMER DIALOG BOX>
oDoc.Close False
Set oDoc = Nothing
'<HIDE WORD IF THERE ARE NO OTHER INSTANCES>
If KillMe = True Then
moApp.Visible = False
End If
'</HIDE WORD IF THERE ARE NO OTHER INSTANCES>
Screen.MousePointer = vbNormal
Exit Function
No_Bugs:
If Err.Number = "91" Then
Resume Next
ElseIf Err.Number = "462" Then
MsgBox "Spell Checking Is Temporary Un-Available!" & vbNewLine & "Try Again After Program Re-Start.", _
vbOKOnly + vbInformation, "ActiveX Server Not Responding"
Screen.MousePointer = vbNormal
ElseIf Err.Number = 429 Then
Set moApp = Nothing
Resume Next
Else
MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbInformation, App.ProductName
Screen.MousePointer = vbNormal
End If
End Function
'*********************************************************
'Example usage:
'Behind a form (Form1)
'
'Add a single or multi-line textbox to your form
'Add a command button (Command1) to invoke the spell checking.
Option Explicit
Private Sub Command1_Click()
'<SPELL CHECK>
Text1.Text = SpellMe(Text1.Text)
End Sub
Private Sub Form_Load()
'<CALL THE SPELLME INITIALIZATION PROCEDURE BEFORE ANY USE>
InitializeMe
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If KillMe = True Then
moApp.Quit False
End If
Set moApp = Nothing
End Sub
Last edited by RobDog888; Jul 21st, 2005 at 01:19 PM .
Reason: Spelling error :lol:; Another spelling error :(, Line Break fix; Hide Word Fix
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 19th, 2005, 07:40 PM
#2
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.
Jul 19th, 2005, 08:38 PM
#3
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 20th, 2005, 02:29 PM
#4
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
Jul 20th, 2005, 03:04 PM
#5
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 01:23 PM
#6
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 01:40 PM
#7
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
this is a test, this is only s ttest
After
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 01:44 PM .
Jul 21st, 2005, 01:43 PM
#8
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 01:47 PM
#9
Re: Advanced VB/Office Guru™ SpellChecker™
This also doesnt get detected in MS Word.
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 02:00 PM
#10
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.
Jul 21st, 2005, 02:13 PM
#11
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 05:35 PM
#12
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.
Jul 21st, 2005, 05:38 PM
#13
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 05:46 PM
#14
Re: Advanced VB/Office Guru™ SpellChecker™
Here is the script file I use.
VB Code:
<!--
+---------------------------------------------------------------------------+
Function: Spell Checker
Description: This script uses Microsoft Word to check the spelling in
posts. Word is assumed to be present.
+---------------------------------------------------------------------------+
-->
<SCRIPT LANGUAGE = "VBScript">
Dim objWord
Dim objDoc
Dim objWindow
Dim objSource
Dim objSelect
Dim objSelectRange
Dim strResult
Set objWindow = window.external.menuArguments
Set objSource = objWindow.event.srcElement
Set oDocument = objWindow.document
Set objSelect = oDocument.selection
Set objSelectRange = objSelect.createRange()
'Create a new instance of word Application
Set objWord = CreateObject("word.Application")
'new
'Dim dlg
'Set dlg = objWord.Dialogs
If objSource.tagName = "TEXTAREA" Then
select case objWord.version
'Office 2000
case "9.0"
with objWord
.WindowState = 2
.Visible = True
end with
Set objDoc= objWord.Documents.Add( , ,1, True)
'Office XP
case "10.0"
with objWord
.windowstate = 2
.Visible = False
end with
Set objDoc= objWord.Documents.Add( , ,1, True)
with objWord
.windowstate =2
.Visible = True
end with
'Office 97
case else ' Office 97
Set objDoc= objWord.Documents.Add
end select
objDoc.Content=objSelectRange.text
objDoc.CheckSpelling
'dlg(828).Show(0)
strResult = left(objDoc.Content, len(objDoc.Content) - 1)
' This part may not work if you don't use IE
If objSelectRange.text = strResult Then
' There were no spelling errors, so give the user a
' visual signal that something happened
window.alert("The spelling check is complete.")
End If
' Replace the selected text with the corrected text
objSelectRange.text = strResult
'Clean up
objDoc.Close False
Set objDoc= Nothing
objWord.Application.Quit True
Set objWord= Nothing
end if
</SCRIPT>
Jul 21st, 2005, 05:58 PM
#15
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 06:05 PM
#16
Re: Advanced VB/Office Guru™ SpellChecker™
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.
Jul 21st, 2005, 11:21 PM
#17
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:
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 21st, 2005, 11:27 PM
#18
Re: Advanced VB/Office Guru™ SpellChecker™
Sep 2nd, 2005, 10:46 AM
#19
New Member
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
Sep 2nd, 2005, 08:01 PM
#20
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 2nd, 2005, 08:47 PM
#21
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Sep 2nd, 2005, 10:35 PM
#22
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 18th, 2006, 10:13 AM
#23
Hyperactive Member
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:
Private Sub Command0_Click()
Me.Text1 = SpellMe(Me.Text1)
End Sub
Private Sub Command3_Click()
InitializeMe
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If KillMe = True Then
moApp.Quit False
End If
Set moApp = Nothing
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
Jan 18th, 2006, 10:24 AM
#24
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:
Private Sub Form_Unload(Cancel As Integer)
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 18th, 2006, 10:29 AM
#25
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:
Private Sub SpellMe()
Application.DoCmd.RunCommand acCmdSpelling
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 18th, 2006, 10:41 AM
#26
Hyperactive Member
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:
Public Function Spellcheck(TextStr As String) As String
Set WordApp = CreateObject("Word.Application")
WordApp.Documents.Add
Dim wordrange As Word.Range
Set wordrange = WordApp.ActiveDocument.Range(0, 0)
wordrange.Text = TextStr
WordApp.Visible = True
WordApp.Activate
wordrange.CheckSpelling , , True
wordrange.CheckGrammar
Spellcheck = wordrange.Text
wordrange.Text = ""
WordApp.Documents.Close (False)
WordApp.Quit
Set WordApp = Nothing
End Function
But this has odd glitches which I was hoping your code would sort out.
Jan 18th, 2006, 10:46 AM
#27
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 18th, 2006, 11:07 AM
#28
Hyperactive Member
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.
Jan 18th, 2006, 11:09 AM
#29
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 18th, 2006, 11:56 AM
#30
Hyperactive Member
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.
Jan 18th, 2006, 12:27 PM
#31
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:
Option Compare Database
Private Sub SpellMe()
Me.Text0.SelStart = 0
Me.Text0.SelLength = Len(Me.Text0.Text)
Application.DoCmd.RunCommand acCmdSpelling
End Sub
Private Sub Form_Click()
SpellMe
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 18th, 2006, 12:35 PM
#32
Hyperactive Member
Re: Advanced VB/Office Guru™ SpellChecker™
Thanks that works, assume Access doesn't have a grammer checker though.
Jan 18th, 2006, 12:39 PM
#33
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 19th, 2006, 04:01 AM
#34
Hyperactive Member
Re: Advanced VB/Office Guru™ SpellChecker™
Jan 19th, 2006, 05:32 AM
#35
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 19th, 2006, 06:17 PM
#36
New Member
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
Feb 7th, 2006, 07:14 AM
#37
New Member
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
Jul 21st, 2006, 01:23 PM
#38
Frenzied Member
Re: Advanced VB/Office Guru™ SpellChecker™
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
Jul 21st, 2006, 01:55 PM
#39
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-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jul 31st, 2006, 04:05 AM
#40
Frenzied Member
Re: Advanced VB/Office Guru™ SpellChecker™
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 04:33 AM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width