Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have the below vb script (as an external file) to open the QV document and print the report as PDF and save it at the defined folder. The problem that i face is that the script opens the QV file and i see a message saying 'Printing document --- Page 1 of 1' but i don't see the pdf file at the defined location.
Can someone please help me resolve this problem?
==========================================================================================
Dim QV, ActiveDocument, Document
'Const OVER_WRITE_FILES = True
Document = "H:\test.qvw"
set Qv = CreateObject("QlikTech.QlikView")
QV.OpenDoc Document, "", ""
set ActiveDocument = Qv.ActiveDocument
Print_PDF "Report1", "Document\RP01"
ActiveDocument.GetApplication.Sleep 5000
Sub Print_PDF(ReportName, ReportID)
Dim pdfjob
Dim sPDFName
Dim sPDFPath
'sPDFName = ReportName & " -1 "
sPDFName = "Report-1"
sPDFPath = "H:\test"
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
WScript.Sleep(5000)
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
'ActiveDocument.GetApplication.Sleep 20
WScript.Sleep(5000)
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Sub
================================================================================
I assume that there is somewhere a small (syntax) error - maybe something like:
sPDFPath = "H:\test\"
instead of
sPDFPath = "H:\test"
I'm not sure if the print is then silently cancelled - I think it will be rather ignired and the default settings will be applied and you will find the print within a windows temp-folder.
- Marcus