ActiveX to Search and Replace in MS-Word

I have a routine that creates MS Word Documents that works just find setting fonts, tabs formatting etc.
It is using ActiveX controls.
I am trying to introduce a function that will do "Find and Replace" and am going through grief trying to get it to work.
Here is the AcuCobol logic I am trying to use:
 
 
01 WORD-DOC-RANGE-HANDLE     HANDLE OF RANGE.
 
     MOVE LOW-VALUES TO WS-REPLACED-TEXT, WS-REPLACEMENT-TEXT.
     STRING "Vancouver"           DELIMITED BY SIZE INTO WS-REPLACED-TEXT.
     STRING "NeverNever Land" DELIMITED BY SIZE INTO WS-REPLACEMENT-TEXT.
 
     MODIFY PRIMARY-WORD-APPLICATION-HANDLE  Documents::Add() GIVING WORD-DOC-HANDLE.
     INQUIRE WORD-DOC-HANDLE CONTENT IN WORD-DOC-RANGE-HANDLE. 
     USE WORD-DOC-RANGE-HANDLE @Find
     MODIFY  ^@Text = WS-REPLACED-TEXT
                   ^@Replacement::@text = WS-REPLACEMENT-TEXT
                   ^@MatchCase = 0
                   ^@MatchWholeWord = 0
                   ^@MatchWildcards = 0
                    ^@MatchSoundsLike = 0
                    ^@MatchAllWordForms = 0
                    ^@Forward = 1
                    ^@Wrap = 0
    END-USE.
    MODIFY WORD-DOC-RANGE-HANDLE @Find::EXECUTE (1, 0, 0, 0, 0, 0, 1, 0, 0, 1).
 
Thanks for your assistance...
 

Tags: