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.
VB Code:
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
'Office 2000
Case "9.0"
Set objDoc = objWord.Documents.Add(, , 1, True)
'Office XP
Case "10.0", "11.0"
Set objDoc1 = objWord.Documents.Add(, , 1, True)
Set objDoc2 = objWord.Documents.Add(, , 1, True)
'Office 97
Case Else ' Office 97
Set objDoc = objWord.Documents.Add
End Select
Me.Text1.SetFocus
objDoc1.Content = Text1.Text
objDoc1.CheckSpelling
strResult1 = Left(objDoc1.Content, Len(objDoc1.Content) - 1)
Me.Text2.SetFocus
objDoc2.Content = Text2.Text
objDoc2.CheckSpelling
strResult2 = Left(objDoc2.Content, Len(objDoc2.Content) - 1)
If Text2.Text = strResult2 Then
Text1.SetFocus
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
End If
End If
'Clean up
objDoc1.Close False
objDoc2.Close False
Set objDoc1 = Nothing
Set objDoc2 = Nothing
objWord.Application.Quit True
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.SetFocus
Text1.Text = strResult1
Text2.SetFocus
Text2.Text = strResult2
Exit Sub
End Sub
How would you approach this?