Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Help with spellcheck of form fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hlngus@hotmail.com - 23 Jan 2007 18:08 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.