*Form.ButtonPrint.Click OLECMDID_SAVEAS = 4 OLECMDID_SAVECOPYAS = 5 OLECMDID_PRINT = 6 OLECMDEXECOPT_PROMPTUSER =1 OLECMDEXECOPT_DONTPROMPTUSER = 2 lcfile="C:\hello.pdf" && print output file name ERASE (lcfile) DO case case TYPE("ThisForm.oleControl1.Document.GetVersions")="C" and; "pdf"$LOWER(ThisForm.oleControl1.Document.GetVersions) * pdf file displayed * OLECMDID_SAVECOPYAS does not work , the user dialog cannot be skipped, etc * ThisForm.oleControl1.Execwb(OLECMDID_SAVECOPYAS ,OLECMDEXECOPT_DONTPROMPTUSER, lcfile) ThisForm.oleControl1.Execwb(OLECMDID_SAVEAS ,OLECMDEXECOPT_DONTPROMPTUSER) oShell = CreateObject("WScript.Shell") lcWindowSaveASTitle="SAVE A COPY" ln=SECONDS() DO WHILE NOT oShell.AppActivate(lcWindowSaveASTitle) AND SECONDS()-ln<5 WAIT WINDOW time 1.0 "" ENDDO if oShell.AppActivate(lcWindowSaveASTitle) oShell.SendKeys("%n") oShell.SendKeys(lcfile+"{ENTER}") WAIT WINDOW TIMEOUT 1.0 "" endif oShell=.null. IF file(lcfile) WAIT WINDOW TIMEOUT 1.0 "File "+lcfile + " has been created." endif CASE TYPE("ThisForm.oleControl1.Document")="O" * NOT pdf file displayed =APRINTERS(aa) llpdfprinter=.f. FOR ia=1 TO ALEN(aa,1) llpdfprinter= ("pdf"$LOWER(aa[ia,1])) IF llpdfprinter EXIT endif ENDFOR IF llpdfprinter lccurprinter=SET("PRINTER",2) oWSHNet = CREATEOBJECT('Wscript.Network') oWSHNet.SetDefaultPrinter(aa[ia,1]) ThisForm.oleControl1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0) * it generates User Dialog and with Windows Title depending on the pdf printer * if the title is known, then use * oShell = CreateObject("WScript.Shell * oShell.AppActivate(.... and so on oWSHNet.SetDefaultPrinter(lccurprinter) oWSHNet = .Null. ELSE WAIT WINDOW "PDF Printer not found?!" ENDIF ENDCASE