Basically a company using access 97 runtime with office 2003 want to see if they can use the 2003 spell checker as the 97 office spellchecker is no longer installed. So I want to use this code in an access form.
I was hoping to loop through all the controls on the form but first altered your code slightly to see how it would handle two text boxes.
Private Sub Command0_Click()
Dim objWord As Object
Dim objDoc1, ojbDoc2 As Object
Dim strResult1, strResult2 As String
'Create a new instance of word Application
Set objWord = CreateObject("word.Application")
Select Case objWord.Version
Set objDoc = objWord.Documents.Add(, , 1, True)
Case "10.0", "11.0"
Set objDoc1 = objWord.Documents.Add(, , 1, True)
Set objDoc2 = objWord.Documents.Add(, , 1, True)
Case Else ' Office 97
Set objDoc = objWord.Documents.Add
objDoc1.Content = Text1.Text
strResult1 = Left(objDoc1.Content, Len(objDoc1.Content) - 1)
objDoc2.Content = Text2.Text
strResult2 = Left(objDoc2.Content, Len(objDoc2.Content) - 1)
If Text2.Text = strResult2 Then
If Text1.Text = strResult1 Then
' There were no spelling errors, so give the user a
' visual signal that something happened
MsgBox "The spelling check is complete.", vbInformation + vbOKOnly
Set objDoc1 = Nothing
Set objDoc2 = Nothing
Set objWord = Nothing
' Replace the selected text with the corrected text. It's important that
' this be done after the "Clean Up" because otherwise there are problems
' with the screen not repainting
Text1.Text = strResult1
Text2.Text = strResult2
How would you approach this?