Discussion Board for collaboration on QlikView Scripting.
I am trying to automatically save various reports as PDF. I need them to have different file names.
I have a field called ID, and i need to make a loop in that field and save each report in the same folder but with different name.
So, I need a macro to do a loop in the ID field that generates each report for each customer and save them in the same folder with the output file name.
Go to Solution.
' Designed for early bind, set reference to PDFCreator
'/// Change the output file name here! ///
set fo = ActiveDocument.Fields("CUUID")
set selo = fo.GetSelectedValues
for i = 0 to selo.Count-1
sPDFName = selo.Item(i).text
sPDFPath = "C:\Users\"
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
If .cStart("/NoProcessingAtStartup") = False Then
If .cStart("/NoProcessingAtStartup", True) = False Then
.cVisible = True
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
' Print the QlikView Report
ActiveDocument.PrintDocReport "RP05", "PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
' in VBScript use WScript.Sleep(20)
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
Set pdfjob = Nothing
I have a similar problem and the macros I have found so far in community does not work. QV does not report any problem with the macro but the macro is still asking me to introduce the filename.