Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I think the site is just incredible....I am learning more here than anywhere else before and am looking forward to being able to help someone .... this is my idea of what the Internet is supposed to do..."

Geography

Where in the world do Tek-Tips members come from?

Microsoft: Visual FoxPro FAQ

COM and Automation

Word SpellChecker Example
Posted: 4 Oct 03 (Edited 18 Feb 05)

Slighthaze = NULL



The following is a good working example of how to use Microsoft Word's SpellChecker (CheckSpelling method of the document object).

CODE

PUBLIC oForm
oForm = createobject("clsspellcheck")
oForm.show()

DEFINE CLASS clsspellcheck AS form
    Autocenter = .T.
    Top = 0
    Left = 0
    Height = 493
    Width = 375
    DoCreate = .T.
    Caption = "WORD SPELLCHECKER"
    Name = "Form1"

    ADD OBJECT edit1 AS editbox WITH ;
        Height = 372, ;
        Left = 12, ;
        TabIndex = 2, ;
        Top = 84, ;
        Width = 348, ;
        ControlSource = "", ;
        Name = "Edit1"

    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 48, ;
        Left = 276, ;
        Height = 27, ;
        Width = 84, ;
        Caption = "Spell Check", ;
        TabIndex = 1, ;
        Name = "Command1"

    ADD OBJECT label1 AS label WITH ;
        AutoSize = .T., ;
        BackStyle = 0, ;
        Caption = "Double-click inside Editbox or click Spell Check button", ;
        Height = 17, ;
        Left = 38, ;
        Top = 462, ;
        Width = 297, ;
        TabIndex = 5, ;
        ForeColor = RGB(0,0,255), ;
        Name = "Label1"

    ADD OBJECT label3 AS label WITH ;
        WordWrap = .T., ;
        BackStyle = 0, ;
        Caption = "Special thanks and credit to http://www.foxite.com/archives/0000020310.htm", ;
        Height = 37, ;
        Left = 12, ;
        Top = 47, ;
        Width = 264, ;
        TabIndex = 7, ;
        Name = "Label3"

    PROCEDURE findword
        LOCAL lcPath, lcResult, lcFileName, lcRetVal, lcCurdir, lnHandle, llRetVal
        lcPath = space(0)
        lcResult = space(255)
        llRetVal = .F.
        lcFileName = ADDBS(FullPath( Curdir()))+sys(3)+[.doc]
        lnhandle = fcreate(lcFileName,0)
        fclose(lnHandle)
        DECLARE INTEGER FindExecutable in shell32 string @lcFileName, string @lcPath, string @lcResult
        IF FindExecutable( @lcFileName, @lcpath, @lcResult) > 32

           IF [WINWORD] $ Upper(lcResult)
              llRetVal = .T.
           ENDIF
        ENDIF
        erase lcFileName
        return llRetVal
    ENDPROC

    PROCEDURE Init
        LOCAL cString
        cString = "On the Product Download page, we haave updated our VFPCOM utility " + ;
                "to fully support Visual FoxPro 8.0. It has the same feetures and functionality " + ;
                "as the Visual FoxPro 7.0 version, but is now fully compatible with " + ;
                "Visual FoxPro 8.0. The VFPCOM utility allows you to extend Visual " + ;
                "FoxPro interoperability with other COM and ADO components. This utility " + ;
                "is a COM server that provides additional functionality when you use ADO " + ;
                "and access COM events with your Visual FoxPro 8.0 applications." + CHR(13) + ;
                "As I mentioned in my last letter, Microsoft has reeleased Visual FoxPro 8.0. " + ;
                "We are now busy working on Service Pack 1 (SP1) for Visual FoxPro 8.0. SP1 " + ;
                "for Visual FoxPro 8.0 is in beta now. I said that SP1 for Visual FoxPro 8.0 " + ;
                "would be released sometime in Setpember 2003 online for free download. " + ;
                "In our efforts to ensure quality and stability, it appears we will complete " + ;
                "SP1 the last week of September, which means it will actually be available " + ;
                "online for free download in early October." + CHR(13) + ;
                "Communities make it possible to get answers to your technical questions " + ;
                "concerning Visual FoxPro 8.0. You'll save time by tapping into a community " + ;
                "of peers who are building applications similar to yours. In addition, we've " + ;
                "collected technical support options and information on training and events. " + ;
                "And it's all free. For a great resource reference for related Visual FoxPro " + ;
                "community resources, refer to the Visual FoxPro Community Resource listings."

        thisform.edit1.Value = cString
    ENDPROC

    PROCEDURE edit1.DblClick
        LOCAL loWord, lnOldMousePointer
        lnOldMousePointer = this.Mousepointer
        this.Mousepointer = 11
        IF DODEFAULT()
           IF NOT thisform.FindWord()
              Messagebox("Word not installed on this machine...",48,_screen.caption)
              return .F.
           ELSE
              WAIT WINDOW NOWAIT "Spellchecking starts..."+CHR(13)+;
              " Please wait"
              IF VARTYPE( loWord ) <> 'O'
                 loWord = CREATEOBJECT('word.application')
              ENDIF
              IF VARTYPE ( loWord ) = "O"
                 loword.windowstate = 0
                 loWord.move(1000,1000)
                 loWord.documents.ADD()
                 WITH loWord
                    .documents(1).content = this.VALUE
                    WAIT WINDOW NOWAIT "Spellchecking has started..."+CHR(13)+;
                    " Please wait"
                    .documents(1).CheckSpelling()
                    .SELECTION.WholeStory
                    IF .selection.text <> this.VALUE
                       WAIT WINDOW NOWAIT "Spellchecking finished"+CHR(13)+;
                       "Your text will be replaced"
                       this.VALUE = .SELECTION.TEXT
                       REPLACE (this.CONTROLSOURCE) WITH (this.VALUE)
                    ELSE
                       WAIT WINDOW NOWAIT "Spellchecking finished"+CHR(13)+;
                       " No typos found"
                    ENDIF
                    .documents(1).CLOSE(.F.)
                    .QUIT
                 ENDWITH
                 loWord = .NULL.
                 RELEASE loWord
              ELSE
                 MESSAGEBOX("Sorry, I can not start Word",48,_SCREEN.CAPTION)
                 RETURN .F.
              ENDIF
              WAIT CLEAR
           ENDIF
        ENDIF
    ENDPROC

    PROCEDURE command1.Click
        thisform.edit1.DblClick()
    ENDPROC

ENDDEFINE

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close