Hey Gang,
I've been using a nifty bit of code to incorporate Word's spell checker into my program and it works great with Word95 and 97, but I'm starting to receive automation errors with Word2000. I'm not familiar with the major changes in Word2000 as far as automating tasks goes, so if anyone has any suggestions and/or code ideas to help fix this error, I'd be very appreciative. Also, if anyone has been playing with OfficeXP, I'd really like to prepare the code for either automating with that version, or at least ignoring it until which time I can figure out it's automation scheme. Thanks in advance.
WORD SPELL CHECK AUTOMATION CODE:
When the form loads, I use this function to test for Word:Code:Private Function FN_SpellCheck(strTextToVerify As String) As Boolean On Error GoTo FN_SpellCheckErr Dim oWord As Object Dim strSelection As String Set oWord = CreateObject("Word.Basic") With oWord .AppMinimize .FileNewDefault .EditSelectAll ' done immediately before to minimize possibility of user ' interaction with the clipboard Clipboard.Clear Clipboard.SetText strTextToVerify, vbCFText .EditPaste .StartOfDocument On Error Resume Next .ToolsSpelling On Error GoTo 0 .EditSelectAll .EditCOPY strSelection = Clipboard.GetText(vbCFText) If Mid(strSelection, Len(strSelection), 1) = Chr(13) Then strSelection = Mid(strSelection, 1, Len(strSelection) - 1) End If If Len(strSelection) > 1 Then strTextToVerify = strSelection FN_SpellCheck = True End If .FileCloseAll 2 .AppClose End With Set oWord = Nothing txtFile.Text = strSelection MsgBox ("Spell Check is complete"), vbInformation Exit Function FN_SpellCheckErr: MsgBox ("SpineText encountered the following error while attempting to spell check your file" _ & ", Error #" & Err.Number & " " & Err.Description), vbExclamation Exit Function End Function
Code:If IsAppPresent("Word.Document\CurVer", "") Then End If Public Function IsAppPresent(strSubKey$, strValueName$) As Boolean IsAppPresent = CBool(Len(GetRegString(HKEY_CLASSES_ROOT, strSubKey, strValueName))) End Function




Reply With Quote