2 Replies Latest reply: Jul 30, 2014 8:34 AM by Sebastian Pereira RSS

    Export Report PDFCreator by loop

    Iñigo Elviro Bodoy

      Hello everybody:

       

      I am using the next macro to print automatically one report for diferents suppliers:

       

      Sub ReportPrint 

           Set soc = ActiveDocument.Fields("Supplier Description") 

           Set socPossible = soc.GetPossibleValues 

           For i = 0 to socPossible.Count-1 

                soc.Select socPossible.Item(i).Text 

                ActiveDocument.GetApplication.WaitForIdle 

                ActiveDocument.PrintDocReport "RP05", "PDFCreator" 

           Next 

      End Sub 

       

      The macro works very good, but I would like to complete it, inserting the name of every pdf automatically with the combination of three fields: "Supplier Description";"Year" and the Last "Month".

       

      Thanks in advance.

        • Re: Export Report PDFCreator by loop

          Hi Iñigo,

           

          You can create an object type PDFCreator and configure the PDF filename like this:

           

          - Get the field values for "Year" and the Last "Month" as you are already doing for "Supplier Description"

          - Create a string variable for the report filename (ex. Dim sPDFName) and stuff it with the desired field values (ex. sPDFName = ReportName & " - " & FieldValue)

          - In the PDF object type, configure the  item  .cOption("AutosaveFilename") = sPDFName

           

           

          Like the code below:

           

          Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")

           

          With pdfjob

                If .cStart("/NoProcessingAtStartup") = False Then

                   If .cStart("/NoProcessingAtStartup", True) = False Then

                         Exit Sub

                   End if

                   .cVisible = True

                End If

                .cOption("UseAutosave") = 1

                .cOption("UseAutosaveDirectory") = 1

                .cOption("AutosaveDirectory") = sPDFPath

                .cOption("AutosaveFilename") = sPDFName

                .cOption("AutosaveFormat") = 0 ' 0 = PDF

                .cClearCache

              End With

           

           

          I got this from Qlik Tips: Qlik Tips: Printing Reports to PDF using PDFCreator

           

          Regards,

          Marina C.

          • Re: Export Report PDFCreator by loop
            Sebastian Pereira

            Iñigo, If it was useful, why don't you mark as answered?