Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am using the following macro to produce multiple PDF files for a report, one per selection in a particular field (Manager):
sub CreateReportPDFs
Set val=ActiveDocument.Fields("Manager").GetPossibleValues(20000)
For i = 0 to val.count-1
set manager = val.Item(i)
ActiveDocument.Fields("Manager").Select manager.text
PrintPDF "C:\Test\Report - " & manager.text & ".PDF", "no"
ActiveDocument.PrintReport("RP05"), "Bullzip PDF Printer", false
Next
ActiveDocument.ClearAll true
end sub
There are 21 possible selections in the Manager field and this script successfully creates 21 PDFs. The problem is the file names are out of sync with the actual selections: manager 1's report saves with manager 2's name, and this repeats all the way down. The 21st PDF for the final selection defaults to QlikViewPrinting.PDF since it doesn't have a selection to drop in.
Any clue why my macro causes this mismatch?
Thanks!
After re-writing it 20 different ways with the same result I finally stumbled on to the answer. I switched lines 6 and 7 and it is now working as intended:
sub CreateReportPDFs
Set val=ActiveDocument.Fields("Manager").GetPossibleValues(20000)
For i = 0 to val.count-1
set manager = val.Item(i)
ActiveDocument.Fields("Manager").Select manager.text
ActiveDocument.PrintReport("RP05"), "Bullzip PDF Printer", false
PrintPDF "C:\Test\Report - " & manager.text & ".PDF", "no"
Next
ActiveDocument.ClearAll true
end sub
Thanks!
After re-writing it 20 different ways with the same result I finally stumbled on to the answer. I switched lines 6 and 7 and it is now working as intended:
sub CreateReportPDFs
Set val=ActiveDocument.Fields("Manager").GetPossibleValues(20000)
For i = 0 to val.count-1
set manager = val.Item(i)
ActiveDocument.Fields("Manager").Select manager.text
ActiveDocument.PrintReport("RP05"), "Bullzip PDF Printer", false
PrintPDF "C:\Test\Report - " & manager.text & ".PDF", "no"
Next
ActiveDocument.ClearAll true
end sub
Thanks!
Hi,
the command PrintPDF "C:\Test\Report - " & manager.text & ".PDF", "no"
returns back the the macro.
The macro creates allways the same filename : QlikView Printing.pdf
Do I have to do modifications on Bullzip PDF Printer?
thanks
and regards
Bumin
Bumin,
In my example, manager.text is used to construct a filename for the PDF that contains the current selection in the Manager field that the macro is looping over. Are you trying to dynamically change the PDF filename in a similar way?
If you want to paste your complete macro I would be happy to take a look.
Hi ckipling,
the macro is almost the same as in your example
-------------------------------------------
sub CreateReportPDFs
Set val=ActiveDocument.Fields("HausID").GetPossibleValues(20000)
For i = 0 to val.count-1
set manager = val.Item(i)
msgbox manager.text
ActiveDocument.Fields("HausID").Select manager.text
ActiveDocument.PrintReport("RP03"), "Bullzip PDF Printer", false
PrintPDF "C:\Temp\Report - " & manager.text & ".PDF", "no"
Next
'ActiveDocument.ClearAll true
end sub
--------------------------------------------
I want to print for each valiue of HausID one PDF with as a filename somethnig with HasuID
When I delete the line commencing with PrintPDF it prints for each HausID one PDF but with the same name "QlikView Printing.pdf"
thanks
Bumin