ACC: How to Use MS Word to Edit and Spell Check a Memo FieldID: Q96544
|
Moderate: Requires basic macro, coding, and interoperability skills.
You can use a word processor to edit memo fields stored in Microsoft
Access tables. Then you can check the spelling and grammar in your data.
This article describes how to use Microsoft Word for Windows to edit memo
fields.
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 on Access Basic, please refer
to the "Introduction to Programming" manual in Microsoft Access version
1.x, or the "Building Applications" manual, Chapter 3, "Introducing Access
Basic," in version 2.0.
Note the following information before trying the example:
'******************************************************
'Declarations section of the module
'******************************************************
Option Explicit
'=====================================================
'The following function EditMemo() calls Microsoft
'Word for Windows
'=====================================================
Function EditMemo (MyEditBox As Control)
Dim X%, LineInFile$, NewLine$, FileNum%, CarriageReturn_LineFeed$
CarriageReturn_LineFeed$ = Chr$(13) & Chr$(10)
FileNum% = FreeFile
Open "TEMP.TXT" For Output As #FileNum%
'Save the text to temporary file for Microsoft Word for WINDOWS
If Not IsNull(MyEditBox) Then
Print #FileNum%, MyEditBox
Else
MsgBox "There is no text to edit. Abort."
Exit Function
End If
Close #FileNum%
X% = Shell("WINWORD.EXE TEMP.TXT", 3)
MsgBox "Press Any Key to Return" ' required to pause the function
'Assume completion of the edits in Microsoft Word. Now read the text
'and place it back into the edit control.
FileNum% = FreeFile
Open "TEMP.TXT" For Input As #FileNum%
NewLine$ = ""
Do While Not EOF(FileNum)
Line Input #FileNum%, LineInFile$
If NewLine$ <> "" Then
NewLine$ = NewLine$ & CarriageReturn_LineFeed$
End If
NewLine$ = NewLine$ & LineInFile$
Loop
MyEditBox = NewLine$
Close #FileNum%
End Function
Object: Text box
------------------------
ControlName: Last Name
ControlSource: Last Name
Object: Text box
------------------------------
ControlName: Notes
ControlSource: Notes
OnDblClick: =EditMemo([Notes])
For a solution that replaces the MsgBox routine, please see the following
article in the Microsoft Knowledge Base:
Q99940 ACC: How to Wait for a Shelled Process to Finish
Additional query words: spell check
Keywords : kbinterop kbprg
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 19, 1999