Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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.
N-printing is better option for you as Jonathan said.
Vikas
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.
hi nagraj,
thanks for the reply
but its giving an error
ActiveX component can't create object: 'Word.Application'
any suggestion on this
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,
There you can save your PDF.
Hope this Helps,
PFA,
Hirish
HI,
Check this,
-Hirish
Nishit,
You need to change the current local security level as "Allow system access". Press Ctrl + M and change the security level like below
Or you can press Ctrl + Shift + M and change the selection to "Give System Access to Module Security".