Access97 - Spellcheck

A

Abay

Is there a way to have a memo field automatically checked for spelling & not
to have to manually click on the "Spelling Icon"?

Thanks in advance!

Abay
 
T

Tom Wickerath

I believe this code was previously posted by Arvin Meyer. You can call it from a command button
on the form, or use the form's Before_Update event procedure. You'll need to have the Office
spell checking feature installed.

Tom



Public Function Spell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
Dim ctlSpell As Control
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False
' Enumerate Controls collection.
For Each ctlSpell In frm.Controls
If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next

DoCmd.SetWarnings True
End Function


________________________________________


Is there a way to have a memo field automatically checked for spelling & not
to have to manually click on the "Spelling Icon"?

Thanks in advance!

Abay
 
A

Abay

I almost got it working ... the only problem is that the spell checker runs
for every field on the form & not just the memo field. I changed the
function to an event procedure and had it execute "on exit" from the Memo
(Notes) field, but with no luck.

I am a neophyte at this and use the simplest of sub-routines on my forms ...
my guess is that I need to change the focus from the whole form to just the
Notes field .. would appreciate any help on it ..

Following is the changed code

Private Sub Notes_Exit(Cancel As Integer)
'Public Function Spell()
' Arvin Meyer 9/17/1998
' Adapted from code by Terry Wickenden
Dim ctlSpell As Control
Dim frm As Form
Set frm = Screen.ActiveForm
DoCmd.SetWarnings False

' Enumerate Controls collection.
For Each ctlSpell In frm.Controls
If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
..SetFocus
..SelStart = 0
..SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next

DoCmd.SetWarnings True
End Sub

Abay
 
D

Douglas J. Steele

It's checking every textbox because that's what the routine tells it to do:

For Each ctlSpell In frm.Controls
If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
..SetFocus
..SelStart = 0
..SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next

If you want to only check a specific control, change that to:

Set ctlSpell = frm.Controls(nameofmemofield)
If Len(ctlSpell) > 0 Then
With ctlSpell
..SetFocus
..SelStart = 0
..SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If


Replace nameofmemofield appropriately.
 
A

Abay

Many thanks .. will do as you say ..

Abay


Douglas J. Steele said:
It's checking every textbox because that's what the routine tells it to do:

For Each ctlSpell In frm.Controls
If TypeOf ctlSpell Is TextBox Then
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If
End If
Next

If you want to only check a specific control, change that to:

Set ctlSpell = frm.Controls(nameofmemofield)
If Len(ctlSpell) > 0 Then
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
End If


Replace nameofmemofield appropriately.
 
T

Tom Wickerath

Tyler,

Why not try the procedure written by Arvin Meyer, which I posted in the message dated 9/21/2004
at 3:24 PM? This procedure is designed to check the spelling for all textbox controls on a form.
Just drop a copy of Public Function Spell() into a new module, and call it from command buttons
on whatever form you wish, ie:

Private Sub cmdSpell_Click()

Call Spell

End Sub


It doesn't get much simpler that this....

Tom
_____________________________________________


Hello, Im a new commer to this forum but here goes my lil trouble. I am not really good at
programming as of yet and I am looking to have a spell check button on my Form for the Current
pages for all the field on the page. Here is the code I am using:

Code:
Private Sub cmdSpell_Click()
On Error Resume Next

Dim ctlSpell As Control

' Check the spelling in the selected text box
Set ctlSpell = Screen.PreviousControl
If TypeOf ctlSpell Is TextBox Then
If IsNull(Len(ctlSpell)) Or Len(ctlSpell) = 0 Then
MsgBox "There is nothing to spell check."
ctlSpell.SetFocus
Exit Sub
End If
With ctlSpell
.SetFocus
.SelStart = 0
.SelLength = Len(ctlSpell)
End With
DoCmd.RunCommand acCmdSpelling
Else
MsgBox "Spell check is not available for this item."
End If

ctlSpell.SetFocus

End Sub

My problem is this here: "Set ctlSpell = Screen.PreviousControl" what should I set it to so that
it spell checks from one Text and the ones that follow it?

*****************************************
* A copy of the whole thread can be found at:
* http://www.accessmonster.com/uwe/Forum.aspx/access/30377
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abuse.aspx?aid=10c604df86e44260af096d6abdba216d
*****************************************
 
Top