If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Spell check.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-04, 03:30
christyxo christyxo is offline
Registered User
 
Join Date: Oct 2003
Location: London
Posts: 291
Question Spell check.

Hi guys,

I'm having a problem with my database where people are making a number of spelling mistakes and not spell checking this.

Does anybody know of a code that would run the spellchecker?
Reply With Quote
  #2 (permalink)  
Old 08-25-04, 21:23
SCIROCCO SCIROCCO is offline
Registered User
 
Join Date: Mar 2004
Location: www.scirocco.ca
Posts: 346
How To Automate Word From Visual Basic or Visual Basic for Applications For Spell Checking

Word's Automation model contains a CheckSpelling function that lets you check the spelling of a document hosted in Word. By using Word Automation, developers can dynamically create a new document, add some text they want to check, and then have Word check the spelling. This article shows you how to automate Word to provide this functionality.

You can use this code sample from either Microsoft Visual Basic or Microsoft Visual Basic for Applications without any changes. However, the sample assumes that you are using a Visual Basic client to create a new project.
Creating a Spell Check Client

Start Visual Basic and create a new Standard EXE project. Form1 is created by default.

Add a TextBox control and CommandButton to Form1.

In the code window for Form1, add the following code:

Code:
Option Explicit

Private Sub Command1_Click()
    Dim oWord As Object
    Dim oTmpDoc As Object
    Dim lOrigTop As Long
      
    ' Create a Word document object...
    Set oWord = CreateObject("Word.Application")
    Set oTmpDoc = oWord.Documents.Add
    oWord.Visible = True
   ' Position Word off screen to avoid having document visible...
    lOrigTop = oWord.Top
    oWord.WindowState = 0
    oWord.Top = -3000
    ' copy the contents of the text box to the clipboard
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Clipboard.Clear
    Clipboard.SetText Text1.SelText

    ' Assign the text to the document and check spelling...

    With oTmpDoc
        .Content.Paste
        .Activate
        .CheckSpelling
      
       ' After user has made changes, use the clipboard to
       ' transfer the contents back to the text box
        .Content.Copy
        Text1.Text = Clipboard.GetText(vbCFText)
        ' Close the document and exit Word...
        .Saved = True
        .Close
      End With
      Set oTmpDoc = Nothing
      
      oWord.Top = lOrigTop
      oWord.Quit
      Set oWord = Nothing
      
   End Sub
Compile and run the program. Press the Command1 command button to run the spell check. Word's spell check dialog box appears to confirm the spelling of the words "mispelled", "textt", "receive", and "resultes". After you correct the misspelled words, the text is returned to the text box.

http://support.microsoft.com/default...NoWebContent=1
__________________
http://www.scirocco.ca/images/banner...occobanner.gif

Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

Or try our Ask An Expert service to answer any of your questions!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On