Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

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

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

hi, im looking to do the same thing. Create a button that prints a PDF via Access Point. We use CutePDF here.

Did you find a solution to the problem?

Not applicable

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

I did not,

Most users have the PDF software set as their default, so it is not a huge issue for me, but I was never able to get this to work in v8.5

pkelly
Valued Contributor

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

The attached word document may partly help you.

This shows how we export to a PDF but we use a set printer (QlikViewPDDF)...

Hope this helps you get somewhere down the line to solving your issue.

Not applicable

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

Hi Paul, thanks for your help and suggestion.

I tried using your code (adapting it for CutePDF) but it didnt work when executed.

------

sub PrintReport
printReportPDF "C:\qlikviewreport.pdf"
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.PrintReport "test", "CutePDF"
ActiveDocument.GetApplication.Sleep 10000
end sub
'===========================================================================
Function printReportPDF(pdfOutputFile)

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\CutePDF\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\CutePDF\BypassSaveAs", "1", "REG_SZ"
Set WSHShell = nothing

End function
'===========================================================================

-------------

Somehow i dont thinks it likes the line in bold.

Its a shame QlikView doesnt clarify exactly how to configure the use of pdfs in QV documents.

Regards

j

pkelly
Valued Contributor

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

I am assuming that test is your report name. You need to use the report id which is RP01 (or similar)....

nathanfurby
Valued Contributor

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


J Trof wrote:ActiveDocument.PrintReport "test", "CutePDF"


I believe the second parameter also needs to be the name of the printer as installed on your machine. By default I think it is actually "CutePDF Writer"

Also - the functionality of the printReportPDF function will not work as the registry keys you are trying to edit do not exist for Cute PDF.

pkelly
Valued Contributor

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

based upon what Nathan is saying can i suggest that you download QlikViewPDF which is free?

Not applicable

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

Thanks for the tips. I modified my script to the following:

----

sub PrintReport
printReportPDF "qlikviewreport.pdf"
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.PrintReport "RP01", "CutePDF Writer"
ActiveDocument.GetApplication.Sleep 10000
end sub
'===========================================================================
Function printReportPDF(pdfOutputFile)

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\CutePDF Writer\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\CutePDF Writer\BypassSaveAs", "1", "REG_SZ"
Set WSHShell = nothing

End function
'===========================================================================

-----

This worked well and printed the report in pdf using 'CutePDF Writer' . Would anyone have any idea how to do the following with my script:

  • Print current sheet on QV document (not a specified report)?
  • Print to desktop (without user input)

Any help would be great

Thanks

pkelly
Valued Contributor

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

On printing without user input, what I did was create a button on a hidden sheet then created the VBS below which was called from windows scheduler at various points......

Dim objQV

Dim boolLoopAgain

boolLoopAgain = False

Do

On Error Resume Next

boolLoopAgain = False

' Try to grab a running instance of QlikView...

Set objQV = GetObject(, "QlikTech.QlikView")

' MsgBox objQV

If TypeName(objQV) = "Global" Then

' QlikView is Running

boolLoopAgain = True

Else

Set MyApp = CreateObject("QlikTech.QlikView")

Set MyDoc = MyApp.OpenDoc ("C:\QlikViewDocuments\Timbmet_Live\Reports\15TS.qvw","","")

Set ActiveDocument = MyDoc

ActiveDocument.Reload

ActiveDocument.GetSheetObject("BU104").Press

End If

Loop While boolLoopAgain

Community Browser