Hi Stefan,
I'm afraid we're perhaps facing a WinCom limitation.
First, as an information, note that
wdReplaceAll refers to a constant....and GDC is only supporting constants on their numeric forms . See also the documentation, especially the "Supported syntax" part:
https://4js.com/online_documentation/fjs-gdc-manual-html/?path=fjs-gdc-manual#c_gdc_WinCOM_API.htmlYou'll find in %GDCDIR%\etc\wincom.cst , a list of constants with their corresponding numeric values. This list is not exhaustive, you may find a lot of other constants with their numeric values by searching on the web (The list is now quite old as based on Microsoft Office XP).
If we're taking your example, the numeric value referring to
wdReplaceAll is 2 (wdReplaceAll=2). So constants must always be replaced by their numeric equivalent in the 4GL code.
But in your case this is not the real limitation...perhaps I'm wrong but I'm afraid the problem is that. :
Selection.Find.Execute Replace:=wdReplaceAll is a "non parenthesis" notation, which is mentioned as an unsupported notation in the documentation (at the same URL as above). So we'd need to find an equivalent with a parenthesis notation. And unfortunately, from what I tested,
Selection.Find.Execute (Replace:=2) doesn't seem to work, at least in Word 2010.
A small workaround that works for replacing an occurence would be possibly the following :
#First find the text to replace:CALL ui.Interface.frontCall("WINCOM","SetProperty", [wdapp,"Selection.Find.Text", "some text"],[wddoc])
#Execute the search. Text of the search will be selected:CALL ui.Interface.frontCall("WINCOM","CallMethod", [wdapp,"Selection.Find.Execute"],[wddoc])
#Type the text that will replace the other one:CALL ui.Interface.frontCall("WINCOM","CallMethod", [wdapp,'Selection.TypeText("a new text")'],[wddoc])
Now if somebody has a better suggestion, it is really welcome :)
Regards,
Lionel