* body of your main program oShell = CreateObject("WScript.Shell") oShell.run("ysetfilename.exe") oShell=null oExcel=CreateObject("Excel.Application") oExcel.visible=.T. oExcel.Workbooks.OPen("c:\book1.xls") oExcel.ActivePrinter = "Win2PDF on Ne00:" oExcel.Activesheet.PrintOut(,,,,,.t.) oExcel=null ReturnStand alone exe file:
* body of stand alone ysetfilename.exe if version(2)=0 _screen.left=-5000 endif PRIVATE oShell, Ltimer, Starttime starttime=SECONDS() oShell = CreateObject("WScript.Shell") Ltimer=createobject("_Force",60000,1000) read events Ltimer=.NUll. oShell=.Null. Return *---------------------------------------- Define class _Force as Timer Interval = 1000 Name = "ForceOL" timeoutdef = 60000 Procedure INIT Lparameter pnTimeOut, pInterval if type("pnTimeOut")="N" this.timeoutdef=pnTimeOut endif if type("pInterval")="N" this.Interval=pInterval ENDIF endproc Procedure Timer if oShell.AppActivate("Print to File") ERASE C:\temppdf.pdf oShell.SendKeys("C:\temppdf.pdf{ENTER}") CLEAR events ENDIF IF SECONDS()-starttime>=this.timeoutdef/1000 clear events ENDIF Endproc EnddefineYou may make it more robostic with parameters and passing file name and key combination as needed.