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

Can I do a "Print as PDF" in macro code?

Hi All,

I have a basic report that needs to be "printed" showing the selected criteria and the results. No problem. I put a button on the sheet to do the PrintReport function so the user doesn't try and print when they have not made sufficient selections. (i.e. massive report).

The question that has come up is: You can right click on a listbox etc. and select Print as PDF and Qlikview knows how to automatically select whichever PDF writer / driver you have installed. Can the same thing be done from the buttons macro code? I can get it to work when I know the name of the driver, such as "CutePDF" but since this is from an access point I won't know the name therefore can I select the PDF writer the same way that menu option does?

Thanks!

Rob

V 8.5

17 Replies
Not applicable
Author

Hello all,

The script is working for me, but it's not autosaving Tongue Tied

I work with CutePDF (QV9). When pushing the programmed button, it generates the report but asks me where to save it with which name.

Greetings,
Jochen

Miguel_Angel_Baeyens

Hello Jochen

I'd recommend you to check the code samples in this post.

Hope it helps!

Not applicable
Author


Miguel A. Baeyens wrote:
Hello Jochen
I'd recommend you to check the code samples in this post.
Hope it helps!<div></div>


Tried it, still asks me where and how to save it.

Miguel_Angel_Baeyens

Hello Jochen,

I've used this code and it's working for me

'***************************************************'Functions creates the reports in PDF format'***************************************************sub CreateReports tempFolder = "C:\Temp" reportID = "RP01" reportName = reportID'Create the file name with path reportFile = tempFolder & "\" & reportID & "_" & reportName & ".pdf" 'print the report printReportPDF reportID, tempFolder 'Call the function 'Rename the report 'checkOutputFile reportFile, tempFolder 'Call the function'call ClearDefault() 'Call the functionend sub'***************************************************'Actual function to print the PDF format without being asked for location to save'***************************************************function printReportPDF(oReport, pdfLocation) Set WSHShell = CreateObject("WScript.Shell") WSHShell.RegWrite "HKCU\Software\CUSTPDF Writer\DefaultLocation", pdfLocation, "REG_SZ" WSHShell.RegWrite "HKCU\Software\CUSTPDF Writer\UseJobName", "1", "REG_SZ" WSHShell.RegWrite "HKCU\Software\CUSTPDF Writer\UseDefaultLocation", "1", "REG_SZ" 'QV Print ActiveDocument.PrintReport oReport, "PDFCreator",false set WSHShell = nothing end function


Credits to Steve Fish.

Hope that helps

Not applicable
Author

Same problem, I think it's a CutePDF-problem. I'll try an other PDF-creator first

nathanfurby
Specialist
Specialist

I blame QlikTech for all the recent questions regarding PDF printing - they have changed the PDF Printer that they provide and the old posts detailing how this works no longer apply.

You can change the registry keys as Miguel suggests or you can just change the settings on the 'New' QlikView PDF Printer as I have detailed here: http://community.qlik.com/forums/t/17253.aspx

Actually, looking at Miguel's code I can't see how that specifies the filename of the output - it just uses the 'tempFolder' variable in the registry modification not the 'reportFile' variable. In the thread I just specified I also detail how you can change the name of the file when using the official QlikView PDF Printer.

The reason this is not working if you are using CutePDF is that I do not think that the registry keys you are trying to change exist for CutePDF. On my machine it looks like the CutePDF keys are here: HKEY_CURRENT_USER\Software\Acro Software Inc\CPW

I don't know if it is possible to manipulate them on the fly, you will have to test. Or just download the QlikView PDF Printer.

jorosoft
Partner - Contributor
Partner - Contributor

HI

I'm struggeling with same problem

Not that I don't know the settings needed for the bullzip pdf printer.

The createobject runs perfect on my Qlikview local client, but NOT in the access point.

So the createobject to the object Wshell doesn't work neither

Thanks

jorosoft
Partner - Contributor
Partner - Contributor

HI

I'm struggeling with same problem

Not that I don't know the settings needed for the bullzip pdf printer.

The createobject runs perfect on my Qlikview local client, but NOT in the access point.

So the createobject to the object Wshell doesn't work neither

Thanks

Did you get it work ?