I found what I thought was the perfect solution to spellchecking individual words using automation of MS WORD from VFP9 (SP2). When I started using it, it worked PERFECTLY, then, all of a sudden, it quit. "QUIT" meaning WORD was always returning a TRUE condition even when the word in question was obviously misspelled. Details follow:
WORD - MS Office 365
VFP9 (SP2)
Windows 10
This code is in the INIT procedure of my Form:
PUBLIC oWord
oWord=CREATEOBJECT("Word.Application")
(WORD always fires up perfectly)
Then I have a TEXTBOX on the form in which the following code appears in the LostFocus event:
lCorrect = .F.
Store "JNHYGT" to answer
lCorrect = oWord.CheckSpelling(answer)
set step on
IF lCorrect
(I ALWAYS land here)
ELSE
MESSAGEBOX(ALLTRIM(answer) + " is NOT a valid word",0)
ENDIF
lCorrect ALWAYS comes back as TRUE.
Now it gets interesting - When I run this in Debug mode and STOP the execution where indicated, and then go to the COMMAND window and call WORD's spellchecker with the same "JNHYGT", it comes back false!!
I reinstalled VFP9 which did nothing. As I said, when I first wrote this code, it worked PERFECTLY and then all of a sudden, it started to fail. I assume you may think it is an environmental issue on my computer which is a reasonable assumption so I am looking for trouble shooting suggestions rather than a simple solution.
WORD - MS Office 365
VFP9 (SP2)
Windows 10
This code is in the INIT procedure of my Form:
PUBLIC oWord
oWord=CREATEOBJECT("Word.Application")
(WORD always fires up perfectly)
Then I have a TEXTBOX on the form in which the following code appears in the LostFocus event:
lCorrect = .F.
Store "JNHYGT" to answer
lCorrect = oWord.CheckSpelling(answer)
set step on
IF lCorrect
(I ALWAYS land here)
ELSE
MESSAGEBOX(ALLTRIM(answer) + " is NOT a valid word",0)
ENDIF
lCorrect ALWAYS comes back as TRUE.
Now it gets interesting - When I run this in Debug mode and STOP the execution where indicated, and then go to the COMMAND window and call WORD's spellchecker with the same "JNHYGT", it comes back false!!
I reinstalled VFP9 which did nothing. As I said, when I first wrote this code, it worked PERFECTLY and then all of a sudden, it started to fail. I assume you may think it is an environmental issue on my computer which is a reasonable assumption so I am looking for trouble shooting suggestions rather than a simple solution.