Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
thierrytt1102
Partner - Creator II
Partner - Creator II

Macro export Reports to multiple PDF

Hi all,

May I ask you to help me for a problem. This might be easy but I didn't studied comuting science.

I'd like to export my report RP01 to PDF files. But I don't want one pdf file for all the values. I'd like to have one pdf for one value (let's say the Region)

So I made my researches on this forum but couldn't find a simple code that loops all my values for printing my report RP01. The result of the macro sould be something like this:

in C:/QlikViewReports

RP01_Brazil.pdf

RP01_USA.pdf

RP01_France.pdf

...

I'm using PDF Creator and a personal version of QV11.

I found how to print some objects to pdf by looping values but not reports.

Thank you very much for your help!

T T

18 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

Yes.  I use 64bit OS all the time.

davdiste
Partner - Creator
Partner - Creator

Hi Stephen,

I’ve tried to implement the macro directly within Qlik, but it doesn't work.

Probably I've made some mistakes because I'm not very familiar with vb.

Anyway, you can find below your macro highlighting in bold the parts I’d like to change.

May you please have a look if I should change something else?

Thanks, Davide


    Dim FieldName
        FieldName = "Seg"
    set mySelections = ActiveDocument.Fields(FieldName).GetPossibleValues

    Dim i
for i = 0 to mySelections.Count - 1
Dim FieldValue
FieldValue = mySelections.Item(i).text

        ActiveDocument.Fields(FieldName).Select FieldValue
Print_PDF FieldValue, "
My Report", "RP01"     
    Next

Sub Print_PDF(FieldValue, ReportName, ReportID)
' Designed for early bind, set reference to PDFCreator

    Dim pdfjob
    Dim sPDFName
    Dim sPDFPath


    sPDFName = ReportName & " - " & FieldValue
    sPDFPath = "C:\PDFReports"
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
  ActiveDocument.PrintReport ReportID, "PDFCreator"


    Do Until pdfjob.cCountOfPrintjobs = 1


   ActiveDocument.GetApplication.Sleep 20


' in VBScript use WScript.Sleep(20)


    Loop


pdfjob.cPrinterStop = False

    Do Until pdfjob.cCountOfPrintjobs = 0


     ActiveDocument.GetApplication.Sleep 20


' in VBScript use WScript.Sleep(20)

    Loop

pdfjob.cClose

    Set pdfjob = Nothing

  End Sub

ActiveDocument.PrintReport ReportID, "PDFCreator"

stephencredmond
Luminary Alumni
Luminary Alumni

Where, exactly, is it stopping working?

davdiste
Partner - Creator
Partner - Creator

    Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")

stephencredmond
Luminary Alumni
Luminary Alumni

Did you install PDFCreator?

Anonymous
Not applicable

Could this be a case of PDFCreator 2.0?

http://forums.pdfforge.org/discussion/30741/pdfcreator-2-0-vbscript-support

Kind regards

Niklas

davdiste
Partner - Creator
Partner - Creator

Thanks Stephen and Nicklas,

I've verified and the version of PDF creator is the 2.0.2.


I'll look for a precedent version and I'll try again.

Bye
Davide

davdiste
Partner - Creator
Partner - Creator

Hi,


With PDF creator 1.0 it works.

Thanks a lot!

Davide

thomas_skariah
Creator III
Creator III

Hi Stephen,

I'm using this macro to extract one of the report to multiple pdf, although the reports are generated here, but I'm facing one issue, the macro gets executed when I'm going to edit module without pressing any button or any trigger.

Regards,

Tom