Mike Clark
Member
Hi,
Windows XP, Progress Version 9.1e and Microsoft Word 2003
We have a system which uses a button to invoke Microsoft Word spelling module on an editor box. This has been working quite happily for a few years, until some PC's were upgraded to Vista with Microsoft Office Word 2007, and now when the spell check button is pressed the job just locks up.
I have enclosed the code snippet below, and if any one has any suggestions as what needs to be changed I would be grateful.
Mike
DEF VAR crowstate AS CHAR NO-UNDO.
DEF VAR hcontainer AS HANDLE NO-UNDO.
DEFINE VAR wordAppl AS COM-HANDLE NO-UNDO.
DEFINE VAR i AS INTEGER NO-UNDO.
DEF VAR oldtext LIKE EDITOR_booktext NO-UNDO.
/*
* First we need to determine if we are running on a system with Word for
* Office 95 or Office 97 since the Automation Objects are dramatically
* different. We do this by looking for a particular Object and if it fails
* then we try the other version. This is done by accessing the system
* registry
*/
LOAD "Word.Application" BASE-KEY "HKEY_CLASSES_ROOT" NO-ERROR. /* Open Registry key */
IF error-status:error THEN DO:
/* Office 95 Word
*
* When the Spell Check button is pressed, create an Automation Object
* for Word.Basic
*
* Copy the text from editor_booktext and put into a new file created in Word.
* The spelling check is done on that Word file and all changes are put
* into that unnamed file. This is all done by the ToolsSpelling() method.
*
* Once that completes, we take the updated contents of the unnamed file
* and copy it back into the edit control on the Progress frame. We then
* close the Automation Object without saving the file.
*/
CREATE "Word.Basic" wordAppl.
NO-RETURN-VALUE wordAppl:FileNew.
ASSIGN editor_booktext.
NO-RETURN-VALUE wordAppl:Insert(editor_booktext).
ASSIGN i = wordAppl:ToolsSpelling NO-ERROR.
NO-RETURN-VALUE wordAppl:AppHide("Microsoft Word").
NO-RETURN-VALUE wordAppl:EditSelectAll.
editor_booktext:SCREEN-VALUE = wordAppl:Selection().
NO-RETURN-VALUE wordAppl:FileClose(2).
NO-RETURN-VALUE wordAppl:AppClose("Microsoft Word").
END.
ELSE DO:
UNLOAD "Word.Application". /* Close Registry key */
/* Office 97 Word
*
* When the Spell Check button is pressed,create an Automation Object for
* Word.Application
*
* Copy the text from editor_booktext and put into a new document in an OLE
* Collection. The spelling check is done on that document and all
* changes are put into that document. This is all done by the
* CheckGrammar() method.
*
* Once that completes, we take the updated contents of the document
* and copy it back into the edit control on the Progress frame. We then
* quit the Automation Object.
*/
CREATE "Word.Application" wordAppl.
wordApplocuments:Add().
ASSIGN editor_booktext
oldtext = trim(EDITOR_booktext:SCREEN-VALUE).
wordApplocuments:Item(1):Range(0,0):InsertAfter(editor_booktext).
wordAppl:Options:CheckGrammarWithSpelling = TRUE.
wordApplocuments:Item(1):CheckGrammar().
wordAppl:Visible = FALSE.
PAUSE 0 NO-MESSAGE.
ASSIGN
editor_booktext:SCREEN-VALUE=wordApplocuments:Item(1):Range(0,wordApplocuments:Item(1):Characters:Count):Text.
editor_booktext:SCREEN-VALUE = TRIM(editor_booktext:SCREEN-VALUE).
wordAppl:Quit(0).
END.
RELEASE OBJECT wordAppl.
Windows XP, Progress Version 9.1e and Microsoft Word 2003
We have a system which uses a button to invoke Microsoft Word spelling module on an editor box. This has been working quite happily for a few years, until some PC's were upgraded to Vista with Microsoft Office Word 2007, and now when the spell check button is pressed the job just locks up.
I have enclosed the code snippet below, and if any one has any suggestions as what needs to be changed I would be grateful.
Mike
DEF VAR crowstate AS CHAR NO-UNDO.
DEF VAR hcontainer AS HANDLE NO-UNDO.
DEFINE VAR wordAppl AS COM-HANDLE NO-UNDO.
DEFINE VAR i AS INTEGER NO-UNDO.
DEF VAR oldtext LIKE EDITOR_booktext NO-UNDO.
/*
* First we need to determine if we are running on a system with Word for
* Office 95 or Office 97 since the Automation Objects are dramatically
* different. We do this by looking for a particular Object and if it fails
* then we try the other version. This is done by accessing the system
* registry
*/
LOAD "Word.Application" BASE-KEY "HKEY_CLASSES_ROOT" NO-ERROR. /* Open Registry key */
IF error-status:error THEN DO:
/* Office 95 Word
*
* When the Spell Check button is pressed, create an Automation Object
* for Word.Basic
*
* Copy the text from editor_booktext and put into a new file created in Word.
* The spelling check is done on that Word file and all changes are put
* into that unnamed file. This is all done by the ToolsSpelling() method.
*
* Once that completes, we take the updated contents of the unnamed file
* and copy it back into the edit control on the Progress frame. We then
* close the Automation Object without saving the file.
*/
CREATE "Word.Basic" wordAppl.
NO-RETURN-VALUE wordAppl:FileNew.
ASSIGN editor_booktext.
NO-RETURN-VALUE wordAppl:Insert(editor_booktext).
ASSIGN i = wordAppl:ToolsSpelling NO-ERROR.
NO-RETURN-VALUE wordAppl:AppHide("Microsoft Word").
NO-RETURN-VALUE wordAppl:EditSelectAll.
editor_booktext:SCREEN-VALUE = wordAppl:Selection().
NO-RETURN-VALUE wordAppl:FileClose(2).
NO-RETURN-VALUE wordAppl:AppClose("Microsoft Word").
END.
ELSE DO:
UNLOAD "Word.Application". /* Close Registry key */
/* Office 97 Word
*
* When the Spell Check button is pressed,create an Automation Object for
* Word.Application
*
* Copy the text from editor_booktext and put into a new document in an OLE
* Collection. The spelling check is done on that document and all
* changes are put into that document. This is all done by the
* CheckGrammar() method.
*
* Once that completes, we take the updated contents of the document
* and copy it back into the edit control on the Progress frame. We then
* quit the Automation Object.
*/
CREATE "Word.Application" wordAppl.
wordApplocuments:Add().
ASSIGN editor_booktext
oldtext = trim(EDITOR_booktext:SCREEN-VALUE).
wordApplocuments:Item(1):Range(0,0):InsertAfter(editor_booktext).
wordAppl:Options:CheckGrammarWithSpelling = TRUE.
wordApplocuments:Item(1):CheckGrammar().
wordAppl:Visible = FALSE.
PAUSE 0 NO-MESSAGE.
ASSIGN
editor_booktext:SCREEN-VALUE=wordApplocuments:Item(1):Range(0,wordApplocuments:Item(1):Characters:Count):Text.
editor_booktext:SCREEN-VALUE = TRIM(editor_booktext:SCREEN-VALUE).
wordAppl:Quit(0).
END.
RELEASE OBJECT wordAppl.