Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Saving PDF report issue

Hi,

Very new to this forum and I was trying to code some macro to create and save report in PDF format. I found some code in this forum and its seems to working, but not as I expected. The problem in the below code is it prompts window to save as and then need to press OK to save the repot. But I wanted not to do this. I installed CutePDF writer.

Any suggesion will be appricated and thantks in advance.







Sub PrintReport

Set WSHShell = CreateObject("WScript.Shell")
fln = "C:\myreport.pdf"
RegKey = "HKEY_CURRENT_USER\Software\CutePDF"
WSHShell.RegWrite RegKey & "BypassSaveAs", 1
WSHShell.RegWrite RegKey & "OutputFile", fln,len(fln)
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.PrintDocReport "RP01", "CutePDF Writer"
ActiveDocument.GetApplication.Sleep 2000
WSHShell.RegWrite RegKey & "BypassSaveAs", 0
WSHShell.RegWrite RegKey & "OutputFile", ""
Set WSHShell = nothing

End Sub



8 Replies
prieper
Master II
Master II

Am not sure, whether your script works for the CutePDF. Am using the basically the same code (it has been posted earlier in this forum), but for the QlikView PDF-printer (you may download it from the QV-page):

Sub PrintReport
fPrintReport2PDF "RP04", "c:\temp\test.pdf" ' CALLS FUNCTION
End Sub

Function fPrintReport2PDF(oReport, pdfOutputFile)
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "1", "REG_SZ"
ActiveDocument.PrintReport oReport, "QlikViewPDF", false
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "0", "REG_SZ"
set WSHShell = nothing
End Function


HTH
Peter

Anonymous
Not applicable
Author

Thanks for the reply, I tried to get the QlikviewPDF download and were not found the link... I will try to look on this ...

Anonymous
Not applicable
Author

You should be able to use the CutePDF writer with that macro if you just change the registry key values from ...\QlikViewPDF\.. to ..\CutePDF\...

Not applicable
Author

your change the highlighted line should solve your problem:

Sub PrintReport

Set WSHShell = CreateObject("WScript.Shell")
fln = "C:\myreport.pdf"
RegKey = "HKEY_CURRENT_USER\Software\CutePDF\"
WSHShell.RegWrite RegKey & "BypassSaveAs", 1
WSHShell.RegWrite RegKey & "OutputFile", fln,len(fln)
ActiveDocument.GetApplication.Sleep 2000

[ActiveDocument.PrintDocReport "RP01", "CutePDF Writer"] ===> [ActiveDocument.PrintDocReport "RP01", "CutePDF"]

ActiveDocument.GetApplication.Sleep 2000
WSHShell.RegWrite RegKey & "BypassSaveAs", 0
WSHShell.RegWrite RegKey & "OutputFile", ""
Set WSHShell = nothing

End Sub

Not applicable
Author

I tried the macro suggested by Peter to save the Report to PDF. However, instead of saving the report as a PDF to the specified folder, it just prints the report directly to the printer. I would like to just save the PDF report to a folder without printing it. Below is the macro.


Sub PrintReport
fPrintReport2PDF "RP01", "C:\file.pdf" ' CALLS FUNCTION
End Sub

Function fPrintReport2PDF(oReport, pdfOutputFile)
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "1", "REG_SZ"
ActiveDocument.PrintReport oReport, "QlikViewPDF", false
WSHShell.RegWrite "HKCU\Software\QlikViewPDF\BypassSaveAs", "0", "REG_SZ"
set WSHShell = nothing
End Function


Anonymous
Not applicable
Author

See code below that I used, it work without any issues...

sub PrintReport

'Set The user selection

set v = ActiveDocument.Variables("vOSUSER")
mUser = v.GetContent.String
ActiveDocument.Fields("JiraUser").Select(mUser)


Set WSHShell = CreateObject("WScript.Shell")
fln = "C:\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





Not applicable
Author

What does your vOSUSER variable contain ? Is that just the OSUser function ? How about the JiraUser ? I don't have such a field in my app.

Anonymous
Not applicable
Author

Hi - vOSUSER to get the user prfile and filter based on user name. You can forget the first 3 lines.