I'm wanting to replace the incorrectly spelled user-input text box
value
with Word's suggested item that is chosen. Using the following code,
the replacement is recognized, but how does one make it update the text
box,
instead of just the active doc?
Private Sub startit()
Load UserForm1
UserForm1.Show
End Sub
' UserForm1 code
Private Sub CommandButton1_Click()
Dim focus As Integer
Dim errorstr As String
With ActiveDocument
If .ProtectionType <> wdNoProtection Then .Unprotect
.Range.LanguageID = wdEnglishUS
.Range.NoProofing = False
If Options.CheckGrammarWithSpelling = True Then
.CheckGrammar
Else
.CheckSpelling
End If
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End With
ActiveDocument.Unprotect
Selection.Text = UserForm1.TextBox1.Value
Selection.Range.CheckSpelling IgnoreUppercase:=False, _
customdictionary:="c:\city.dic"
errorstr = Word.Application.CheckSpelling(Word:=Selection.Text)
'
If errorstr = True Then
MsgBox "selection has no spelling errors: "
Else
MsgBox "There are spelling errors: "
focus = 1: GoTo set_focus
End If
Unload Me
Exit Sub
set_focus:
Select Case focus
Case 1: Me.TextBox1.SetFocus
End Select
End Sub
I'm sure it's something simple that is overlooked. Using Word 2000
(9.0.6926 SP-3)
and Windows 2000 (ver 5.0 build 2195 SP-4). Thanks!
Stefan Blom - 29 Jan 2007 13:36 GMT
Did you take a look at
http://word.mvps.org/faqs/macrosvba/SpellcheckProtectDoc.htm?

Signature
Stefan Blom
Microsoft Word MVP
> I'm wanting to replace the incorrectly spelled user-input text box
> value
[quoted text clipped - 56 lines]
> (9.0.6926 SP-3)
> and Windows 2000 (ver 5.0 build 2195 SP-4). Thanks!
hlngus@hotmail.com - 30 Jan 2007 18:59 GMT
> Did you take a look athttp://word.mvps.org/faqs/macrosvba/SpellcheckProtectDoc.htm?
Thanks, I'll check it out.
hlngus@hotmail.com - 30 Jan 2007 19:11 GMT
Does this also apply to a pop-up form that is called by the active
doc?
I apologize for not making this clear.
Doug Robbins - Word MVP - 31 Jan 2007 10:23 GMT
See the thread that was started on 1/23/2007 by Fuzzhead with the Subject
"Spell checking" in the microsoft.public.word.vba.general newsgroup.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Does this also apply to a pop-up form that is called by the active
> doc?
>
> I apologize for not making this clear.
hlngus@hotmail.com - 07 Feb 2007 18:12 GMT
This worked great! Much thanks.