VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin VB.TextBox txtSpell Height = 2055 Left = 120 TabIndex = 1 Text = "This is speled wrong." Top = 0 Width = 4455 End Begin VB.CommandButton cmdSpell Caption = "Command1" Height = 615 Left = 1440 TabIndex = 0 Top = 2400 Width = 1815 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'Speller 'Demonstrates Use of Object variables 'Calling Word from VB 'expects cmdSpell, txtSpell 'Word must be installed and NOT CURRENTLY RUNNING Private Sub cmdSpell_Click() Dim wordApp As Object 'try to open a new version of word Set wordApp = CreateObject("Word.Application") 'Check to see if this works!! 'see if wordApp exists. Nothing is a special null object 'Note also that 'is' is a keyword for comparing objects If wordApp Is Nothing Then MsgBox "couldn't start word!!" End End If 'Add a new document wordApp.Documents.Add 'Activate the document wordApp.activeDocument.Activate 'copy text from vb to word wordApp.activeDocument.Range.InsertAfter txtSpell.Text 'run the spell checker wordApp.activeDocument.CheckSpelling 'select everything wordApp.Selection.wholestory 'copy back to VB txtSpell.Text = wordApp.Selection.Text 'Shut down word wordApp.quit End Sub