Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

PDF Creation Spooling

I have an issue with creating a PDF via a batch file (reload command) and macro.

At first, I thought it to be related to the verison of the QlikView PDF Printer software, but I tried both 7.X and 9.X, only to have both have the exact same issue.
I've read through about a dozen different walkthroughs and macro examples on here but they all seem to either be outdated or reference other community postings (which is a whole other issue since the upgrade of the Community pages)... any help is greatly appreciated!  I have provided emphasis where applicable to point out the 'issues' as I see them occurring on the server.  Note: Email Distribution portion works indepedently, so the PDF creation portion is the only part not working.

1.  Macro (PrintReport) is setup to be called OnPostReload:

sub PrintReport

ActiveDocument.GetApplication.Sleep 2000

Set WSHShell = CreateObject("WScript.Shell")

fln = "E:\QlikView\Exports\Finance\Report.pdf"

ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.PrintDocReport "RP01", "QlikViewPDF"
ActiveDocument.GetApplication.Sleep 2000

Set WSHShell = nothing

MailReport()

end sub 

sub MailReport

strTo = "email@company.com"
fln = "E:\QlikView\Exports\Finance\Report.pdf"

set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Daily Sales Report"
objMessage.From = "email@qlik.company.com"
objMessage.To = strTo

objMessage.TextBody = "DSR"

objMessage.AddAttachment fln

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.company.com"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update
objMessage.Send

end sub

If I 'TEST' the Macro, it works perfectly fine - I get the email within a few seconds of completion.  If I reload (with QlikView open) it also works exactly as intended.

MAIN ISSUE: If I reload the QVW via a command line / batch call (below), it ALWAYS stops while spooling the document to the printer.

I have tried BOTH versions of the PDF printer provided here, and they both behave similarly.  The 9.X version has an extra dialog box in the bottom right whose progress bar never moves.

(batch call)
"C:\Program Files\QlikView\Qv.exe" "E:\QlikView\Access Point\DSR.qvw" /r

I know we've had several dozen (if not hundreds) of previous posts about this, but I've been stuck for a week or more trying all combinations on my own to no avail.  Yet, others on here appear to have this working, but the more I look the more it seems like the newer software (QV 10 / PDFXChange 3.0) seems to have made the legacy instructions incompatible.


I have also verified that the security settings in the module are allowing system access as necessary.

/throwshandsup  XD

1 Solution

Accepted Solutions
Not applicable
Author

Of course I figured this out after finally giving up.

Instead of doing the job OnPostReload, I moved it to OnOpen, and setup a variable (vSendReports) and then modified my batch to call QV.EXE with /vvSendReports=1 and it works fine now.

Must just be the whole 'don't generate PDFs during a reload' issue.  I just did not grasp how to circumvent the problem until I finally caught some extra detail in reply #3 here : http://community.qlik.com/thread/13966?start=0&tstart=0

If anyone else is still struggling, let me know and I'll provide some non-proprietary source.

View solution in original post

1 Reply
Not applicable
Author

Of course I figured this out after finally giving up.

Instead of doing the job OnPostReload, I moved it to OnOpen, and setup a variable (vSendReports) and then modified my batch to call QV.EXE with /vvSendReports=1 and it works fine now.

Must just be the whole 'don't generate PDFs during a reload' issue.  I just did not grasp how to circumvent the problem until I finally caught some extra detail in reply #3 here : http://community.qlik.com/thread/13966?start=0&tstart=0

If anyone else is still struggling, let me know and I'll provide some non-proprietary source.