Click here to Skip to main content
15,891,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm creating a program that check the spelling of the a word. It functioning well....
It check the spelling if the word is in the right spelling. Here is my code :

VB
Option Explicit

Private Declare Function CoAllowSetForegroundWindow Lib "ole32.dll" (ByVal pUnk As Object, ByVal lpvReserved As Long) As Long

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")

    CoAllowSetForegroundWindow oWord, 0

    Set oTmpDoc = oWord.Documents.Add
    ' Position Word off screen to avoid having document visible
    lOrigTop = oWord.Top
    oWord.WindowState = 0
    oWord.Top = -3000

    oWord.Visible = True
    oWord.Activate

    ' 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 the 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.Visible = False

    oWord.Top = lOrigTop
    oWord.Quit
    Set oWord = Nothing
End Sub


My problem is, if the word is wrong spelling the dialog of the word application will not any more open/pop up, I want to just return some value that will determine if the word is wrong spelling, no dialog box will appear any more.

Anybody know about this???? Please I need your help....any idea appreciated...Thanks.
Posted
Updated 20-Sep-11 4:08am
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900