******************************************************************** * Description.......: RunDoc - opens any document * Calling Samples...: * Parameter List....: tcDocument * Created by........: Hilmar Zonneveld November 8, 2001 10:43 * Modified by.......: ******************************************************************** * Sample use: * MyFile = "MySpreadsheet.xls" * RunDoc(MyFile) FUNCTION RunDoc(tcDocument) if vartype(m.tcDocument)<>"C" or !file(m.tcDocument) return .f. && Invalid parameter endif 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) DECLARE INTEGER FindWindow ; IN WIN32API ; STRING cNull, ; STRING cWinName lnResult=ShellExecute(FindWindow( 0, _SCREEN.caption), "Open", tcDocument, "", "c:\temp\", 1) **Error messages if the return value is < 32 IF m.lnResult < 32 DO CASE CASE m.lnResult=2 Wait wind "Invalid association or URL." CASE m.lnResult=31 Wait wind "No association." CASE m.lnResult=29 Wait wind "Can't start application." CASE m.lnResult=30 Wait wind "Application is already open." ENDCASE ENDIF return m.lnResult>=32 ENDFUNC