>>>* Sample use: >>> MyFile = 'C:\Users\Naomi\Downloads\OVER_Clause_and_Ordered_Calculations.doc' >>> RunDoc(MyFile) >>> >>>FUNCTION RunDoc(tcDocument) >>> local lnResult >>> >>> DECLARE INTEGER ShellExecute ; >>> IN SHELL32.dll ; >>> INTEGER nWinHandle, ; >>> STRING cOperation, ; >>> STRING cFileName, ; >>> STRING cParameters, ; >>> STRING cDirectory, ; >>> INTEGER nShowWindow >>> >>> **retreive the main VFP window handle (this handle is used by ShellExecute) >>> >>> lnResult=ShellExecute(_screen.hwnd, "Open", tcDocument, "", "c:\temp\", 1) >>> >>> **Error messages if the return value is < 32 >>> IF lnResult < 32 >>> DO CASE >>> CASE lnResult=2 >>> Wait wind "Invalid association or URL." >>> CASE lnResult=31 >>> Wait wind "No association." >>> CASE lnResult=29 >>> Wait wind "Can't start application." >>> CASE lnResult=30 >>> Wait wind "Application already open." >>> ENDCASE >>> ENDIF >>>ENDFUNC >>>>>>
>>lnResult=ShellExecute(_screen.hwnd, "Open", tcDocument, "", "c:\temp\", 1) >>>>
>>Property HWND not found >>>>
if !file(myFile) Run code that creates it, using the correct version of WORD (or Excel, or ....), based on the provided extension (DOC or DOCX, XLSX etc) endif Open myFile with shellexecute