14 Replies Latest reply: Oct 4, 2010 5:44 AM by Nathan Furbank RSS

    Export to PDF - Doesn't save PDF

    Steve Rowe

      Hi there, I have been at this for days. I need to save a report to a specified file etc. The simplest script I can get from other numerous examples is this -

      sub printRP01
      printReportPDF "C:\TestPDF\myreport.pdf"
      ActiveDocument.PrintReport "RP01", "QlikviewPDF", false
      end sub

      Function printReportPDF(pdfOutputFile)
      Set WSHShell = CreateObject("WScript.Shell")
      WSHShell.RegWrite "HKCU\Software\QlikviewPDF\OutputFile", pdfOutputFile, "REG_SZ"
      WSHShell.RegWrite "HKCU\Software\QlikviewPDF\BypassSaveAs", "1", "REG_SZ"
      Set WSHShell = nothing
      End function

      I have tried all sorts of variations of this but it just won't save RP01 to myreports.pdf in C:\TestPDF.

      Please help?

      Thanks Steve

        • Export to PDF - Doesn't save PDF

          Steve I had to put a sleep call right before the call to ActiveDocumentPrintReport. Try that.

          • Export to PDF - Doesn't save PDF
            Michael Solomovich

            This works for me:

            sub PrintReport
            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.GetApplication.Sleep 2000
            ActiveDocument.PrintDocReport "RP01", "QlikViewPDF"
            ActiveDocument.GetApplication.Sleep 2000
            WSHShell.RegWrite RegKey & "BypassSaveAs", 0
            WSHShell.RegWrite RegKey & "OutputFile", ""
            Set WSHShell = nothing
            end sub

              • Export to PDF - Doesn't save PDF
                Steve Rowe

                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.



                  • Export to PDF - Doesn't save PDF
                    Michael Solomovich

                    Check if the directory exists. QV will not create it if it doesn't exist. Next, chck the permissions. Maybe you cannot write there.
                    What happens if you try to save as PDF manually, without macro?

                      • Export to PDF - Doesn't save PDF
                        Steve Rowe

                        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.


                    • Export to PDF - Doesn't save PDF
                      Amit Deshpande


                      Thanks for sharing the code. I tried it and it fails to save the PDF. It prints it succesfully though. I am working on XP.

                      I have created the directory and given all the necessary permissions.

                      Any thoughts?

                        • Export to PDF - Doesn't save PDF



                          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.


                          Any idea?


                            • Export to PDF - Doesn't save PDF


                              I'm facing exaclty the same problem with win 7. deactivated uac -> no change :-(

                              Anyone a solution?
                              Thanks in advance.

                                • Export to PDF - Doesn't save PDF
                                  Nathan Furbank

                                  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

                                  End Function

                                  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.


                          • Export to PDF - Doesn't save PDF
                            Deepak Kurup


                            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..