Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to export sheet to PDF

Hi,

I want to export sheet to PDF format and save it as pdf file.

Like, i want to have snapshot of whole sheet and save it as PDF.

Is there any macro to achieve this functionality?

5 Replies
vikasmahajan

HOPE THIS HELP YOU

VIKAS

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Not applicable
Author

HI Uday ,

Try This ..

Sub PrintReport()

ActiveDocument.ClearAll

Dim FieldName

FieldName = "Country"

Dim mySelections

set mySelections = _

ActiveDocument.Fields(FieldName).GetPossibleValues

Dim i

for i = 0 to mySelections.Count - 1

Dim FieldValue

FieldValue = mySelections.Item(i).text

ActiveDocument.Fields(FieldName).Select FieldValue

Print_PDF FieldValue, "My Report", "RP01"

Next

End Sub

Sub Print_PDF(FieldValue, ReportName, ReportID)

' This is mostly reference code from the

' PDF Creator documentation

' Designed for early bind, set reference to PDFCreator

Dim pdfjob

Dim sPDFName

Dim sPDFPath

'/// Change the output file name here! ///

sPDFName = ReportName & " - " & FieldValue

sPDFPath = "C:\Temp"

Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")

With pdfjob

If .cStart("/NoProcessingAtStartup") = False Then

If .cStart("/NoProcessingAtStartup", True) = _

False Then

Exit Sub

End if

.cVisible = True

End If

.cOption("UseAutosave") = 1

.cOption("UseAutosaveDirectory") = 1

.cOption("AutosaveDirectory") = sPDFPath

.cOption("AutosaveFilename") = sPDFName

.cOption("AutosaveFormat") = 0 ' 0 = PDF

.cClearCache

End With

' Print the QlikView Report

ActiveDocument.PrintReport ReportID, "PDFCreator"

' Wait until the print job has entered the print queue

Do Until pdfjob.cCountOfPrintjobs = 1

ActiveDocument.GetApplication.Sleep 20

' in VBScript use WScript.Sleep(20)

Loop

pdfjob.cPrinterStop = False

' Wait until PDF creator is finished

' then release the objects

Do Until pdfjob.cCountOfPrintjobs = 0

ActiveDocument.GetApplication.Sleep 20

Loop

pdfjob.cClose

Set pdfjob = Nothing

End Sub

Hope It Helps

vikasmahajan

You need to install free PDF BULLZIP

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
VishalWaghole
Specialist II
Specialist II

Hi Uday,

Hope this link make help for you.

http://community.qlik.com/thread/102666

- Regards

Vishal Waghole.