home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmSpell
- Caption = "OLE Automation with Word"
- ClientHeight = 2175
- ClientLeft = 1095
- ClientTop = 1515
- ClientWidth = 5340
- Height = 2580
- Icon = "frmspell.frx":0000
- Left = 1035
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 2175
- ScaleWidth = 5340
- Top = 1170
- Width = 5460
- Begin VB.CommandButton cmd
- Caption = "Spell Check in Microsoft Word 6.0"
- Height = 420
- Left = 225
- TabIndex = 1
- Top = 1620
- Width = 4875
- End
- Begin VB.TextBox Text1
- Height = 1365
- Left = 225
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 0
- Text = "frmspell.frx":030A
- Top = 180
- Width = 4875
- End
- Attribute VB_Name = "frmSpell"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub cmd_Click()
- Text1 = SpellCheck(Text1)
- End Sub
- Private Sub Form_Load()
- Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
- End Sub
- Public Function SpellCheck(ByVal IncorrectText$) As String
- Dim Word As Object, retText$
- '**************************************************
- ' OLE Automation always returns errors which can
- ' usually be ignored.
- '**************************************************
- On Error Resume Next
- '**************************************************
- ' Create the Object (Word will be opened if it not
- ' currently running).
- '**************************************************
- Set Word = CreateObject("Word.Basic")
- '**************************************************
- ' Change the active window to WinWord, and insert
- ' the text from Text1 into Word.
- '**************************************************
- Word.AppShow
- Word.FileNew
- Word.Insert IncorrectText
- '**************************************************
- ' Perform a spell check.
- '**************************************************
- ' NOTE: Visual Basic will not regain control and
- ' execute the next line until the spell
- ' check is complete.
- '**************************************************
- Word.ToolsSpelling
- Word.EditSelectAll
- '**************************************************
- ' Trim the trailing character from the returned text.
- '**************************************************
- retText = Word.Selection$()
- SpellCheck = Left$(retText, Len(retText) - 1)
- '**************************************************
- ' Close Word and return to Visual Basic.
- '**************************************************
- Word.FileClose 2
- Show
- '**************************************************
- ' Recover the memory being used by the Word object.
- '**************************************************
- Set Word = Nothing
- End Function
-