Hi all I placed Dave's code in a PRG called PrintFile.PRG which accepts as a parameter the full path and name of the file to print.
Elsewhere I have some code that looks like this: <pseudocode> Create text file MyFile.TXT = PrintFile("MyFile.TXT") ERASE("MyFile.TXT") This causes a problem because notepad cannot find the file to print - I need to somehow wait until Notepad finsihes with the file and only then let the ERASE command execute. Any suggestions ? Also is there a way to prevent Notepad printing the file with a (filename) header and (page number) footer ? Many thanks Paul Newton Dave Crozier wrote: > * API Call to print out or OPEN a document > > Declare Integer ShellExecute In Shell32.Dll ; > INTEGER nWinHandle,; > STRING cOperation,; > STRING cFileName,; > STRING cParameters,; > STRING cDirectory,; > INTEGER nShowWindow > > ShellExec("test.pdf","","c:\temp\") > > ********* > Procedure ShellExec (exeName, exeParms, exePath) > Local nStat, errorDesc > > * Use the next line to View > * nStat = ShellExecute(0,"open",exeName,exeParms,exePath,1) > > * Use the next line to Print > nStat = ShellExecute(0,"print",exeName,exeParms,exePath,1) > > * If nStat > 32, then it is the Instance Handle > * To get a Windows Handle see support.microsoft.com/kb/q242308/ > If nStat <= 32 > errorDesc = Icase(nStat=2,"Invalid path or filename", ; > nStat=8,"Insufficient memory", ; > nStat=11,"invalid EXE file", ; > nStat=31,"Invalid action, or no application > associated with the specified file", ; > "Error description not available") > Messagebox("Error "+Ltrim(Str(nStat))+" ... > "+errorDesc,16,"Program did not start.",2000) > Endif > > Return > > Dave Crozier > _______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.