Microsoft KB Archive/132185

= ACC2: Using Microsoft Word Spelling and Grammar Tools in Microsoft Access =

Article ID: 132185

Article Last Modified on 11/6/2000

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Word 6.0 Standard Edition

-



This article was previously published under Q132185



SUMMARY
This article demonstrates how you can use Access Basic code to activate the Spelling and Grammar tools in Microsoft Word for Windows version 6.0 for an embedded Microsoft Word document in Microsoft Access.

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Access Basic, please refer to the "Building Applications" manual.



MORE INFORMATION
The following example assumes you have a Microsoft Access table with an OLE field called MyOle that contains embedded (not linked) Microsoft Word objects.

To use Access Basic code to activate the Microsoft Word Spelling and Grammar tools for an embedded OLE object in a form, follow these steps:

 Create a new form based on the table containing the MyOle field, using the AutoForm Wizard.  On the View menu, click Code, type the following line in the Declarations section of the Module window, and then close the Module window:

     Option Explicit   Add a command button to the form and name it SpellCheck. Set the command button's OnClick property to the following event procedure:

Sub SpellCheck_Click On Error GoTo SpellCheck_Err Dim WordObj As Object

' Set the object variable to the form's embedded OLE control. Set WordObj = Me![MyOle].Object.Application.WordBasic ' Activate the embedded control. MyOle.Action = 7 ' Specify a WordBasic function to perform. WordObj.ToolsSpelling ' Deactivate the embedded control. MyOle.Action = 9 Exit Sub

SpellCheck_Err: If Err = 2763 Then MsgBox "The Spell Check is Complete." Resume Next End If     End Sub   Add a command button to the form and name it GrammarCheck. Set the command button's OnClick property to the following event procedure:

Sub GrammarCheck_Click On Error GoTo GrammarCheck_Err Dim WordObj As Object

' Set the object variable to the form's embedded OLE control. Set WordObj = Me![MyOle].Object.Application.WordBasic ' Activate the embedded control. MyOle.Action = 7 ' Specify a WordBasic function to perform. WordObj.ToolsGrammar 'Deactivate the embedded control. MyOle.Action = 9 Exit Sub

GrammarCheck_Err: If Err = 2763 Then MsgBox "The Grammar Check is Complete." Resume Next End If        End Sub 

NOTE: The error trapping shown above is necessary to avoid an alert message in Microsoft Access. When Microsoft Word completes spelling or grammar checking, it returns a message reporting that the check is complete. Microsoft Access interprets this as an error and generates the following message that you can resolve using error trapping:

Microsoft Word returned the following error:

Microsoft Word - The spelling check is complete.

