Qlik Community

Ask a Question

New to QlikView

If you’re new to QlikView, start with this Discussion Board and get up-to-speed quickly.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Creator
Creator

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
Contributor II
Contributor II

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?