This works for me:
Set WSHShell = CreateObject("WScript.Shell")
fln = "C:\TestPDF\myreport.pdf"
RegKey = "HKEY_CURRENT_USER\Software\QlikViewPDF\"
WSHShell.RegWrite RegKey & "BypassSaveAs", 1
WSHShell.RegWrite RegKey & "OutputFile", fln
ActiveDocument.PrintDocReport "RP01", "QlikViewPDF"
WSHShell.RegWrite RegKey & "BypassSaveAs", 0
WSHShell.RegWrite RegKey & "OutputFile", ""
Set WSHShell = nothing
Hi Michael, thanks for the prompt response. I tried your code and the suggestion from cfrench. Both scripts run but no file gets saved into the C:\TempPDF directory.
Could it be QlikviewPDF printer settings or something? I have set the default printer to QlikviewPDF and run the script. The printer shows that it is printing a file, but no file in the C:\TempPDF directory.
The directory exists with full read/write permissions. I also tried changing the directory. When I Print to PDF, it runs as usual, dialog box opens, choose print and it asks for a location and file name. It's the strangest thing. I paused the printing and looked in the files properties but couldn't find what or where it was printing.
One thing I haven't mentioned is that I am running Windows 7. I am going to try it on Windows XP tomorrow. Will let you know the outcome.
Thanks for your trouble.
I couldn't wait for tomorrow. I ran it on a laptop with Windows XP and it runs perfectly! There must be a setting in Windows 7 somewhere that is preventing the file from saving. I am going to get one of my technical boffins to set me with XP using virtual machine or some other plan.
Thanks once again.
I have the same exactly the same problem. The PDFdriver seems to print, but the file is not saved in the any director.
I use Vista full upgraded. Sometimes ago I used the same file on my computer and it worked.
Also, I have tried the file on other computers (Win Serv 2008 and XP) and it work perfectly.
I have been wondering about this for a few weeks. No one seems to be able to confirm - but I think the "QlikView" pdf writer has changed since other forum members started writing the code involving registry key changes. I have recently installed both version 7 and 9 of the PDF Writer from the QlikView website and neither seems to use the registry keys mentioned.
My workaround so far has been this:
- After installing the QlikView PDF Writer (Version 9) you should have a new pdf printer available in 'Printers and Faxes'
- Right Click on the 'PDF-Xchange 3.0' printer and select 'Properties'
- On the 'General' tab select 'Printing Preferences'
- You can then set options as follows:
As you can see, you can specify the Path that the pdf files will be saved to. Ignore the File Name/Macro settings - these will not work. Instead, you will have to rename the files on the fly in your QV Macro using the file system object. You can do this because the pdf printer will always output the file as 'QlikView Printing.pdf'.
So instead of modifying registry keys my macro function now looks like this:
Function printReportPDF(oReport, pdfOutputFile)
ActiveDocument.PrintReport oReport, "PDF-XChange 3.0", false
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\Temp\QlikView Printing.pdf" , pdfOutputFile
Where 'oReport' is the name of the report in QV to be printed and pdfOutputFile is the full path and name of the pdf file to be created.
In Windows Vista and Windows 7 there is restriction in creating Files in C: dirve even if you are an administrator.
In order to save the file in C: drive you need to enable the UAC control. It will be a tick mark in vista and Slide bar in WIndows 7.
Once you untick the UAC (User Access Control) you will be able to save the file in C: drive. YOu will find the UAC in Control Panel---User Access.
And thanks for the PDf code..