Link to home
Start Free TrialLog in
Avatar of Eric Harris
Eric Harris

asked on

access 2003 using grammar check

Hello Experts.

I have an access 2003 front end which allows users to enter text into a large control. THis control is then merged into a word document, save and printed etc etc etc.

I have a spell check facility built in which works a treat using the following vba code.

    With Me!str_ex_int_free
      If Len(.Value) > 0 Then
        DoCmd.SetWarnings False
        .SetFocus
        .SelStart = 1
        .SelLength = Len(.Value)
        DoCmd.RunCommand acCmdSpelling
        .SelLength = 0
        DoCmd.SetWarnings True
      End If
    End With

does anyone know how I can combine this with a grammar chack similar to how word does it?

Avatar of MrXmas
MrXmas
Flag of United States of America image

EWHTLC,

This is the routine that I use:

'----------------
Public Function SpellIt(ctl As Control)
   Dim wdApp As Word.Application
   Dim wdDoc As Word.Document


    On Error GoTo SpellIt_Err

   Set wdApp = New Word.Application

      If Not IsNull(ctl) Then
         Set wdDoc = wdApp.Documents.Add
         wdApp.Selection.Text = ctl
         wdApp.Dialogs(wdDialogToolsSpellingAndGrammar).Show
         If Len(wdApp.Selection.Text) <> 1 Then
            ctl = wdApp.Selection.Text
         Else
            wdDoc.Close wdDoNotSaveChanges
            wdApp.Quit
            Set wdApp = Nothing
            Exit Function
         End If
         wdDoc.Close wdDoNotSaveChanges
      End If

   wdApp.Quit
   Set wdApp = Nothing

   MsgBox "Spelling and Grammar Check Complete.", vbInformation, "Microsoft Word Spelling And Grammar:"
   Exit Function
   
SpellIt_Err:
    Err.Clear
    ctl.Undo
    MsgBox "We encountered an error in it's conversation with Microsoft Word regarding your comment." & vbCrLf & _
        "As a precaution, any changes made within the grammar and spelling dialog box have not been retained.", _
        vbCritical, "Spelling and Grammar Check NOT Complete:"
End Function
'--------------

In spite of the name, this thing runs spelling *and* grammar.  You just call it with the name of the control.  You do need to set a reference to Microsoft Word in your Tools - References section of the Visual Basic editor.

I had some custom functions embedded in here that I needed to remove for it to work on your system.  Hopefully I caught everything.

--Jim Christmas

Avatar of Eric Harris
Eric Harris

ASKER

That's fine and would work beautiful except that I haven't actually opened my word document. The word processing part of the function is invisible to the user.
So it the actual screen object wher eI'm performing the spellcheck.
EWHTLC,

That's how this function works.  The user doesn't see word, just the spell/grammar check interface that word uses.

--Jim Christmas
Well I have the word element done pretty much.
What I actually want is all the spelling and grammer to have already been performed on the text box on the Access form before submitting my merge with word.
THe users buid up their text as they proccess a case. THey may not necessarily want to print the document until they are completely finished.
Needless to say each time thay chenge their text it is saved until printing.

So my original code perofrms the spell check on the text box on the form. What I need is a grammer check on the text box.

So in summary, it's more of an Access issue than a word issue.
ASKER CERTIFIED SOLUTION
Avatar of MrXmas
MrXmas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your time jim.
You've given me a couple of options and eliminated one which has saved me some time.

Thanks