Advertisement
2002C Miscellaneous #9042

Spell Checker (uses MS Word)

This code uses OLE Automation to allow VB to open an instance of MS Word if the user has it on their system and spell check the contents of a text box. It could easily be modified to work with any control that has text on it. I would recommend better error control than the On Error statement listed here.

AI

Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fuente
original-source
Private Sub cmdSpellCheck_Click()
  'On Error Resume Next 'Best to un-comment this while testing
  Dim objMsWord As Word.Application
  Dim strTemp As String
  Set objMsWord = CreateObject("Word.Application")
  objMsWord.WordBasic.FileNew
  objMsWord.WordBasic.Insert txtMessage.Text 
  objMsWord.WordBasic.ToolsSpelling
  objMsWord.WordBasic.EditSelectAll
  objMsWord.WordBasic.SetDocumentVar "MyVar", objMsWord.WordBasic.Selection
  objMsWord.Visible = False ' Mostly prevents Word from being shown
  strTemp = objMsWord.WordBasic.GetDocumentVar("MyVar")
  txtMessage.Text = Left(strTemp, Len(strTemp) - 1)
  
  objMsWord.Documents.Close (0) ' Close file without saving
  objMsWord.Quit         ' Exit Word
  Set objMsWord = Nothing    ' Clear object memory
  frmMain.SetFocus        ' Return focus to Main form 
End Sub
Comentarios originales (3)
Recuperado de Wayback Machine