Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
We had a macro printing out reports to PDF with Bullzip. New version of the reports contain pictures and we have noticed that if we print with Microsoft Print to PDF the pic quality is much better and therfore would like to switch. The part i am struggling with is how to supress the 'save as' window and save to the path & name given in macro.
The code so far is:
Function printReportPDF(pdfOutputFile)
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Microsoft Print to PDF\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Microsoft Print to PDF\BypassSaveAs", "1", "REG_SZ"
Set WSHShell = nothing
End function
sub PrintUnitReport2
reportFolder = getVariable("ReportFolder")
reportFile = getVariable("vUnitFileName2")
fullpath = reportFolder & reportFile
printReportPDF fullpath
ActiveDocument.PrintReport "RP01", "Microsoft Print to PDF", false
end sub
It does print, but promts 'Save as' window and seems to ignore the function printReportPDF . Any help is highly appreciated.
Ana, I would expect the proper place to dig into this one is actually on the Microsoft Forums, as they are going to be the experts on how to call the Microsoft Print to PDF as well as any parameters etc...
Here are a couple of things I found:
Not sure they are exactly what you need, but may give you some further things to try.
Regards,
Brett
Hi Brett,
Thank you for your answer. The first link offers a solution but for c# and unfortunately, to my knowledge you cannot write a macro in c# inside a QlikView document. Other posts in the links relate to VBS but for the files which already are created and saved as pdf. My challenge is to export a Qlik Report and save it as good quality pdf, no actual printing is needed.
The reason I did not post on some Microsoft forums is that Qlik VBS is not the classical VBS either. I beleive the commonly used call 'ActiveDocument.PrintReport' is specific for QlikView. And what instance it creates is unknown to me which creates questions weather PrintFile() or PrintOut() VB-functions could be used (failed so far during my experiments).
I also found some related questions on just Microsoft forum with no proper answer. I can probably anyway post my own question and see if I can get some help there.
Ana, I may have found your problem, possibly, at least one part of it, you may have the wrong Qlik API here, but you are correct, that API is one of ours. I did a quick search in the API Guide QVW and there are two versions of that API, the one you are using but also one called PrintReportEx, which is going to be the one you need to use if you have an Ajax client trying to do things, as otherwise things are going to only run server-side etc. I just wanted to point that part out, but I do not think that likely answers your underlying question.
The thing I just caught though is the PrintReport API does have 3 parameters whereas the PrintReportEx API only has a single parameter, the Report ID, the other one has the following parameteres:
Hopefully that may allow you to get the print dialog to show and be able to change something there, or if you try the Ex version, I suspect that likely pops up the dialog as well. Hopefully this may help. Just FYI on the Edit Module, I believe the version of VB that is based upon is 3 if I am not mistaken! 🙂
Cheers,
Brett