ACC2: Using MS Word Spelling & Grammar Tools in MS AccessID: Q132185
|
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.
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:
Option Explicit
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
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
Microsoft Word returned the following error:
Microsoft Word - The spelling check is complete.
For more information about OLE Automation, search for "OLE Automation," and
then "Interoperability with Microsoft Word and Microsoft Excel(Common
Questions)" using the Microsoft Access Help menu.
For more information about WordBasic commands available through OLE
Automation, search for "WordBasic," and then "WordBasic Help" using the
Microsoft Word for Windows version 6.0 Help menu.
Additional query words: Word.Basic documents embedding linking
Keywords : kbole IntpOlea
Version : 2.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: April 26, 1999