Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Generate PDF report

hi

i want to generate a report using macro and store it in the PDF format.

the report should contain the screen shot of the activated sheet

and that screenshot should be save in PDF format.

Thanks in advance

15 Replies
andrespa
Specialist
Specialist

Hi Nishit, something like this should works:

Sub Print_PDF(FieldValue, ReportName, ReportID)


    ' Designed for early bind, set reference to PDFCreator

    Dim pdfjob

    Dim sPDFName

    Dim sPDFPath


    '/// Change the output file name here! ///

    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


   ' Print the QlikView Report

    ActiveDocument.PrintReport ReportID, "PDFCreator"


    'Wait until the print job has entered the print queue

    Do Until pdfjob.cCountOfPrintjobs = 1

     ActiveDocument.GetApplication.Sleep 20

        ' in VBScript use WScript.Sleep(20)

    Loop

    pdfjob.cPrinterStop = False


    'Wait until PDF creator is finished then release the objects

    Do Until pdfjob.cCountOfPrintjobs = 0

     ActiveDocument.GetApplication.Sleep 20

        ' in VBScript use WScript.Sleep(20)

    Loop

    pdfjob.cClose

    Set pdfjob = Nothing


End Sub

For your second part of the question, in your reports you can include a text box and put the method "GetActiveSheetId()". That will show you the current active sheet.

For more details in the mcro, please go to this link:

Qlik Tips: Printing Reports to PDF using PDFCreator

Hope it helps.

Cheers,

Andrés

Not applicable
Author

hi andres,

thanks for the reply

but i didn't created any report using report toolbar which given in qlikivew

i want to create the dynamic report using macro

the report include charts dynamically using macro...\

any suggestion on that

jonathandienst
Partner - Champion III
Partner - Champion III

I don't think that it is possible to do that in a macro. Have a look at nPrinting for this purpose. Search here for more information on nPrinting.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
vikasmahajan

N-printing is better option for you as Jonathan said.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
tamilarasu
Champion
Champion

Hi Nishit,

I don't have PDF software in my system, so I just tried to export the screenshot to Word format (But you can modify the macro). Hope this is what you are asking.

Not applicable
Author

hi nagraj,

thanks for the reply

but its giving an error

ActiveX component can't create object: 'Word.Application'

any suggestion on this

HirisH_V7
Master
Master

Hi may be like this,

Got to Reports-> first create a report of with all objects you need on a report ,


Create a report:


Reports -> Edit report-> Add Report -> There open the Report and drag and drop all of your required Objects  -> Such that all will be on that report.


Macro to call Report :

Download Primo PDF and Install it,

Then use this macro-

Sub PDFExport

ActiveDocument.clearall

path="C:\"

'path="D:\Qlikview\Report\"

ActiveDocument.PrintDocReport ("RP01"),"PrimoPDF", false

set rep = ActiveDocument.GetReport("RP01")

reportFile = path & "MIBL_Snapshot"&".pdf"

PrintreportPDF(reportFile)

ActiveDocument.GetApplication.Sleep 12500

end sub

By running this Macro you will get a pop up from like this,

PDF Export Macro-201303.PNG

There you can save your PDF.

Hope this Helps,

PFA,

Hirish


HirisH
“Aspire to Inspire before we Expire!”
HirisH_V7
Master
Master

HI,

Check this,

Macro system Acess.PNG

-Hirish

HirisH
“Aspire to Inspire before we Expire!”
tamilarasu
Champion
Champion

Nishit,

You need to change the current local security level as "Allow system access". Press Ctrl + M and change the security level like below

Capture.PNG

Or you can press Ctrl + Shift + M and change the selection to "Give System Access to Module Security".