Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
spikenaylor1
New Contributor III

Report to PDF using Microsoft Print to PDF

I have looked at the other posts regarding printing to PDF

I just need the code to print the report and save to a location using the default Microsoft Print to PDF

The code opens the Microsoft Print to PDF application, but doesn't automatically print the file to a location, Also if I press cancel or quit the application still goes through the printing process evan though no file has been entered in the save as dialog screen

any pointers or help please

my code is:

Sub Publish 

    'ActiveDocument.reload 

    vReport = "RP03" 'Set report 

    vName = "End of Year Report for " 'Name of output pdf 

    ActiveDocument.PrintReport(vReport), "Microsoft Print to PDF", false  'Printreport 

    reportFile = "c:\PDFs\Operations\" & vName &".pdf" 'Setting outputname 

    MyPrint(reportFile) 'Call pdf printer 

    ActiveDocument.GetApplication.Sleep 5000 

    ActiveDocument.Save 

    ActiveDocument.GetApplication.Sleep 5000 

    ActiveDocument.GetApplication.Quit 

End sub

FUNCTION MyPrint (pdfOutputFile) 

 

    'set obj = CreateObject("Microsoft Print to PDF.PDFPrinterSettings")

    set obj = CreateObject("Shell.Application").Namespace(0).ParseName(strF).InvokeVerb ("Print") 

    obj.SetValue "Output" , pdfOutputFile 

    obj.SetValue "ConfirmOverwrite", "no" 

    obj.SetValue "ShowSaveAS", "never" 

    obj.SetValue "ShowSettings", "never" 

    obj.SetValue "ShowPDF", "no" 

    obj.SetValue "RememberLastFileName", "no" 

    obj.SetValue "RememberLastFolderName", "no" 

    obj.SetValue "ShowProgressFinished", "no" 

    obj.SetValue "ShowProgress", "no" 

    obj.WriteSettings True 

 

END FUNCTION

1 Reply
guillermo_welch
New Contributor II

Re: Report to PDF using Microsoft Print to PDF

As far as I know, you have to call the printer configuration functions (MyPrint) before you actually ask QlikView to print your document.

 

On the other hand,

set obj = CreateObject("Shell.Application").Namespace(0).ParseName(strF).InvokeVerb ("Print")  

¿What is strF?