Lparameters pntipo, pcalias, pcchave #Define DebugListener -2 #Define PrintListener 0 #Define PreviewListener 1 #Define XMLListener 4 #Define HTMLListener 5 lclocal = Justpath(_Screen.cNome_arq_prosi) _ReportOutput = Forcepath("REPORTOUTPUT.APP", lclocal) _ReportPreview = Forcepath("REPORTPREVIEW.APP", lclocal) _ReportBuilder = Forcepath("REPORTBUILDER.APP", lclocal) If File(lcdest) Erase lcdest NORECYCLE Endif lcClasslibs = Set("Classlib") options = " NOEJECT" If Upper("reportlistener")$Upper(lcClasslibs) Else If Version(2)=2 Set Classlib To Home()+"\ffc\_reportlistener.vcx" Additive Else Set Classlib To "_reportlistener.vcx" Additive Endif Endif Local oListener As Object Local oXH As Object Local loPreview As Object pcalias = Substr(pcalias+Space(20),1,20) pcchave = Substr(pcchave+Space(10),1,10) forexpr = Iif(Empty(This.cForExpression),""," for "+This.cForExpression) If pntipo=2 lcrepo = Forcepath(Alltrim(commlog.Nome)+".frx", _Screen.clocalreports) lcdest = Forcepath(Forceext(Alltrim(commlog.Nome), "htm"),_Screen.clocalreports) lcemail = commlog.dest_email lcdstnome = commlog.dest_nome lccdusuario = commlog.cdusuario Else lcrepo = Forcepath(Alltrim(cur_destinos.Nome)+".frx", _Screen.clocalreports) lcdest = Forcepath(Forceext(Alltrim(cur_destinos.Nome), "htm"),_Screen.clocalreports) lcemail = cur_destinos.email lcdstnome = cur_destinos.dest_nome lccdusuario = cur_destinos.cdusuario Endif lcassi = Forcepath("assinatura.htm", lclocal) lclib = "_reportlistener.vcx" If Version(2)=2 lclib = Forcepath("_reportlistener.vcx",Home()+"\FFc\") Endif oHTMLReport = Newobject("HtmlListener", lclib) oHTMLReport.ListenerType = HTMLListener oHTMLReport.TargetFileName = lcdest *Setup HTML Listener as a successor DO (_REPORTOUTPUT) WITH oHTMLReport With oHTMLReport .QuietMode = .T. .TargetFileName = (lcdest) .TargetFileExt = ("HTML") &&"TXT", "LOG", "XML" EndWith If pcalias="pedcompr" Select copedite Endif If "XTC002"$Upper(lcrepo) Select copedite.linha_pfk, copedite.d4pednr, copedite.fornecs_id,; copedite.cdusuario, copedite.d4prodt, copedite.d4qtfat, copedite.unid,; copedite.unid2, copedite.d4qtpec, copedite.d4qtpec2, copedite.d4pruni,; copedite.d4pruni2, copedite.d4prtot, copedite.d4qtok,; Pedcompr.datacompra, Pedcompr.horacompra, Pedcompr.comprador,; Pedcompr.pagamt_id, Pedcompr.valorcompr, Pedcompr.valordesco,; Pedcompr.valortt, Produtos.referencia, Produtos.descricao,; Produtos.resumida, Produtos.vendavelpr, Produtos.referencpr,; Produtos.grupo, Fornecs.fornec_id, Fornecs.nmfantasia, Fornecs.razaosoc,; Fornecs.fisicjurid, Fornecs.contato, Fornecs.endereco, Fornecs.bairro,; Fornecs.cidade, Fornecs.estado, Fornecs.cep, Fornecs.ddd, Fornecs.telefone,; Fornecs.email; FROM ; copedite ; INNER Join Pedcompr ; ON copedite.d4pednr = Pedcompr.compra_id ; INNER Join Produtos ; ON copedite.d4prodt = Produtos.referencia ; INNER Join Fornecs ; ON copedite.fornecs_id = Fornecs.fornec_id; ORDER By copedite.d4pednr, Produtos.descricao; INTO Cursor cur_pesquisa1 ENDIF If Upper(_Screen.cLocaltabelas)$ Set("Path") Else Set Path To (_Screen.cLocaltabelas) Additive ENDIF Report Form (lcrepo) ENVIRONMENT &forexpr TO Printer Prompt NOCONSOLE Object oHTMLReport * * I already try to take out &forexpr and ENVIRONMENT... Using preview clause the report works... * IF USED("cur_pesquisa1") USE IN "cur_pesquisa1" endif _Cliptext=Message() oHTMLReport = "" If File(lcdest) If File(lcassi) lcstr = Filetostr(lcdest) lnmaiorpos = Thisform.ver_maior_htmlpos(lcstr) lcstrass = Filetostr(lcassi) lnpos2 = At("top:4.75417in", lcstrass) If lnpos2>0 And lnmaiorpos<> 0 lcstrass = Stuff(lcstrass, lnpos2, 13, "top:"+Chrtran(Alltrim(Transform(lnmaiorpos,"9999.99999")), Set("point"), ".")+"in") lcstrass = Strconv(lcstrass,9) Endif lnpos = At("</body></html>", lcstr) If lnpos>0 lcstr = Stuff(lcstr, lnpos, 0, lcstrass) =Strtofile(lcstr, lcdest, 0) Endif Endif If Thisform.doenvio_email(lcdest, Alltrim(lcemail), Alltrim(lcdstnome), Alltrim(lccdusuario)) If pntipo=2 Select commlog Scatter Memvar Memo m.dtexec = Datetime() Gather Memvar Memo Endif Endif Endif