<pre lang="vb"> Dim objWord As Object Dim objDoc As Object Dim strResult As String 'Create a new instance of word Application If (Len(txtbox.Text) = 0) Then Else Set objWord = CreateObject("word.Application") objWord.Visible = False Select Case objWord.version 'Office 2000, xp, 2k3 Case "9.0", "10.0", "11.0" Set objDoc = objWord.Documents.Add(, , 1, True) 'Office 97 Case Else Set objDoc = objWord.Documents.Add End Select objDoc.content = txtbox.Text objDoc.CheckSpelling objWord.Visible = False strResult = Left(objDoc.content, Len(objDoc.content) - 1) 'correct the carriage returns strResult = Replace(strResult, Chr(13), Chr(13) & Chr(10)) 'Clean up objDoc.Close False Set objDoc = 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 txtbox.Text = strResult End If Done: Exit Function 'in case user does not have word... Err_Handler: MsgBox Err.Description & Chr(13) & Chr(13) & "Please note you must have Microsoft Word installed to utilize the spell check feature.", vbCritical, "Error #: " & Err.Number Resume Done End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)