Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
wandapec
Partner - Contributor III
Partner - Contributor III

Export to PDF - Doesn't save PDF

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

14 Replies
Not applicable

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

Anonymous
Not applicable

Steve,
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


wandapec
Partner - Contributor III
Partner - Contributor III
Author

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.

Thanks

Steve

Anonymous
Not applicable

Steve
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?

wandapec
Partner - Contributor III
Partner - Contributor III
Author

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.

Steve

wandapec
Partner - Contributor III
Partner - Contributor III
Author

Hi Michael,

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.

It has been a long few days! Tongue Tied

Thanks once again.

Steve

Anonymous
Not applicable

Thanks Steve,
I was thinking of upgrading my home PC. You certainly helped my to choose OS - I'm staying with XP for now. Geeked

deepakk
Partner - Specialist III
Partner - Specialist III

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

Deepak

Not applicable

Michael,

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?