My weekly PDF report mutated into an anual one after January first this year
Hi, Thanks to the usefull information in this forum I managed to create a PDF report that it´s automatically send weekly on QV 8.5 to the users emails.
But after January first this year it began to show all the information stored on the qvd which is several months instead of just a weekly one.
This is the macro I´m using, sorry but I couldn´t managed to give it a good format:
if weekday(ff - 1) = 1 then ActiveDocument.Fields("Año").clear ActiveDocument.Fields("Mes").clear ActiveDocument.Fields("Día").clear ActiveDocument.Fields("Semana").Select(datepart("ww",(ff-2))) set Dia = ActiveDocument.Fields("Día").GetPossibleValues msgcam = ""
for k=0 to Dia.Count-1
ActiveDocument.Fields("Día").Select(Dia.item(k).Text) set cam = ActiveDocument.Fields("Cámara").GetPossibleValues antcam = 0 for i=0 to cam.Count - 1
if (cam.item(i).number - antcam) > 1 then msgbox(cam.item(i).number) for u = antcam + 1 to cam.item(i).number - 1 msgcam = msgcam & "Día " & Dia.item(k).Text & "," & " Cámara " & u & "," & " 24 Horas sin Mediciones " & chr(10) next end if
ActiveDocument.Fields("Cámara").Select(Cam.item(i).text) set med = ActiveDocument.Fields("Veces").GetPossibleValues for j=0 to med.Count-1
if med.Item(j).Number <= 50 then msgcam = msgcam & "Día " & Dia.item(k).Text & "," & " Cámara " & Cam.item(i).text & ", " & round(((72 - med.item(j).number) / 3)) & " Horas sin Mediciones " & chr(10) end if
next ActiveDocument.Fields("Cámara").Clear antcam = cam.item(i).number
next
next if msgcam <> "" then 'msgbox(msgcam) set v = ActiveDocument.Variables("msgcam") v.SetContent msgcam, true end if
Set objMail = CreateObject("CDO.Message") objMail.From = "mail" objMail.To = "mail" objMail.Cc = "mail" objMail.Subject = "Subject" objMail.TextBody = "text" on error resume next
objMail.AddAttachment "c:\QV\Piloto\Reportes\Camaras\ve\TempCamaras.pdf" objMail.send Set objMail = Nothing
end if
end sub
function printReportPDF(oReport, pdfOutputFile) Set WSHShell = CreateObject("WScript.Shell") WSHShell.RegWrite "HKCU\Software\QlikViewPDF\OutputFile", pdfOutputFile, "REG_SZ" WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "1", "REG_SZ" ActiveDocument.PrintReport oReport, "QlikViewPDF", false set WSHShell = nothing end function