2 Replies Latest reply: Sep 14, 2009 8:32 PM by Oleg Troyansky RSS

    Time problem on a macro

    Camilo Lund


      I´m using a macro that sends each monday a weekly report, but has a time problem, first it creates a pdf file on a specific folder then the pdf file is attached to an email and sent. The problem is that it takes about 1 minute for the pdf to be created and at that time the macro already attached the pdf file that was created the l week before.

      Is there any way to avoid this problem???



      [ code ]

      if weekday(ff - 1) = 1 then

      printReportPDF "c:\QV\Repositorio\Reportes\Camaras\ve\TempCamaras.pdf"
      ActiveDocument.PrintReport "RP02", "QlikViewPDF", FALSE

      end if

      Set objMail = CreateObject("CDO.Message")
      objMail.From =
      objMail.To =
      objMail.Cc =
      objMail.Subject =
      objMail.TextBody =
      'on error resume next

      objMail.AddAttachment "c:\QV\Repositorio\Reportes\Camaras\ve\TempCamaras.pdf"
      Set objMail = Nothing
      end sub

      Function printReportPDF(pdfOutputFile)

      Set WSHShell = CreateObject("WScript.Shell")
      WSHShell.RegWrite "HKEY_CURRENT_USER\Software\QlikViewPDF\OutputFile", pdfOutputFile, "REG_SZ"
      WSHShell.RegWrite "HKEY_CURRENT_USER\Software\QlikViewPDF\BypassSaveAs", "1", "REG_SZ"
      Set WSHShell = nothing

      End function

      [ /code ]