H
hlngus
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!
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!