Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
If found some code to produce pdf's .
So I created a module in a testapp (personal edition) to find if it's working for me.
Because there is no debugger and no pdf's are created I added some msgbox lines.
However when running, the macro does not proceed after the first message.(sometimes it stops at some other line)
Pressing F8 does not help.
This is the code :
' VB Script for Printing Reports to PDF using PDFCreator
'Option Explicit
Sub PrintReport()
ActiveDocument.ClearAll
Dim FieldName
FieldName = "City"
msgbox("Working")
Dim mySelections
set mySelections = _
ActiveDocument.Fields(Fieldname).GetPossibleValues
msgbox(mySelections.Count)
msgbox ("Stil working")
Dim i
for i = 0 to mySelections.Count - 1
Dim FieldValue
FieldValue = mySelections.Item(i).text
ActiveDocument.Fields(FieldName).Select FieldValue
Print_PDF FieldValue, "MyReport", "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 = "K:\qlikview bestanden"
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
msgbox(pdfjob.cCountOfPrintjobs)
' debug.print pdfjob.cCountOfPrintjobs
ActiveDocument.GetApplication.Sleep 20
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Sub
Try it without the linebreak with the underline-char - there could be easily an error.
- Marcus
Now my code stops at :
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
Seems to be a common problem.
The world wide web tells me it runs with older versions of pdf creator, but when I succeed in dowloading older versions Google tells me it's unsafe.
Activating .Net Framework doesn't help either
Suggestions someone?
Are within the modul security system access enabled? In general it seems to work: ActiveX component can't create object: 'PDFCreator.clsPDFCreator' and Print Report to PDF with open source PDFCreator.
An alternatively could be to use another PDF printer, like: Re: generate pdf with Xchange.
- Marcus