Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
spikenaylor1
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
guillermo_welch
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?