Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
qv_jagan
Partner - Creator
Partner - Creator

How to create PDF through Macro in Qlikview 11

Hello All,

I want a macro to create PDF Reports. Please provide me the code and an example.

Thanks

5 Replies
Anonymous
Not applicable

qv_jagan
Partner - Creator
Partner - Creator
Author

Thank you so much for your help.

qv_jagan
Partner - Creator
Partner - Creator
Author

I found a solution for the issue. Thanks for your help Johannes Sunden.

You need to download QlikviewPDF Set from Qlikview website download page.

Once after you install the exe file in you desktop.

Use to following code to export data as PDF.

Sub GWP_Macro4r_Email

'...........PDF Export logic.............QlikViewPDF

ActiveDocument.clearall
path="\\inmchn24\ChannelMIS\Centrlal MiS\Daily Reports\Automated Reports\"
'path="D:\Qlikview\Report\"
ActiveDocument.PrintDocReport ("RP01"),"QlikViewPDF", false
set rep = ActiveDocument.GetReport("RP01")
reportFile = path & "SRO_GWP_Dashboard"&".pdf"
printReportPDF(reportFile)

ActiveDocument.GetApplication.Sleep 16000

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

sanketkhunte
Creator II
Creator II

Hi Jagan,

Thank you for your Help.

I am trying with above code but i got the error.

below is the image I have attached - :

Please let me know what is the issue ?

MicroForPDFExport.png

Thanks

Sanket K.

Not applicable

Hi,  qv_jagan. You want to use code or a third party tool to help you creat PDF files?

here are some code maybe useful:

Sub Dagrapport
vReport = "QVreportname" 'Set report
vName = "reportname" 'Name of output pdf
ActiveDocument.PrintReport(vReport), "Bullzip PDF Printer", false 'Printreport
reportFile = "reportpath" & vName &".pdf" 'Setting outputname
MyPrintPDFWithBullZip(reportFile) 'Call pdf printer
ActiveDocument.GetApplication.Sleep 5000
zendDagrapport
End sub
FUNCTION MyPrintPDFWithBullZip (pdfOutputFile)
set obj = CreateObject("Bullzip.PDFPrinterSettings")
obj.SetValue "Output" , pdfOutputFile
obj.SetValue "ConfirmOverwrite", "no"
obj.SetValue "ShowSaveAS", "never"
obj.SetValue "ShowSettings", "never"
obj.SetValue "ShowPDF", "no"
obj.SetValue "RememberLastFileName", "no"
obj.SetValue "RememberLastFolderName", "no"
obj.SetValue "ShowProgressFinished", "no"
obj.SetValue "ShowProgress", "no"
obj.WriteSettings True
END FUNCTION
'===========================================================================
'===========================================================================
function zendDagrapport()
Dim objEmail
Const cdoSendUsingPort = 2 ' Send the message using SMTP
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
SMTPServer = "IP Mailserver"
Const SMTPPort = 25 ' Port number for SMTP
Const SMTPTimeout = 60 ' Timeout for SMTP in seconds
'Sending mail
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
'---------------------------------------------------------------------
' SMTP server details
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout
.Update
'---------------------------------------------------------------------
End With
objEmail.To = "to emailaddress" 'Email Recipient
objEmail.From = "from emailaddress" 'Email Sender
objEmail.Subject = "emailsubject" ' Subject
objEmail.TextBody = "emailbody" 'Text Body
objEmail.AddAttachment "link to file" ' Attachement
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
' msgbox ("Test Mail Sent")
end function

As for myself, I used to creat PDF with the help of a PDF SDK.

It is just one of many but I do appreciate its simple way of processing.

Besides, this site gives a lot of choices for document imaging processing.

Even though I only tried its free trial package to generate PDFs and didn′t check the cost and licensing conditions, it works great for me.

Share with you. Good luck.

Best regards,

Arron