Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Macro to split pdf is not working anymore(pdfcreator 2.5.2)

Hello,

I have a question regarding a macro to split one pdf file into seperate pdf files. It used to work fine, but since last week it doesn't anymore. When I click on the 'Print' button the Edit Module opens where the macro can be edited.

I have checked most of the (security) settings and added a different macro to see if this macro would run and this works.

Does anyone has similar issues with this marcro and pdfcreator? Can it be caused by an update on the pdfcreator side?

This is the code that is used:

Sub Printen()

ActiveDocument.ClearAll

Dim FieldName

FieldName = "Medewerker.Personeelscode"


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", "RP03"

Next



End Sub

Sub Print_PDF(FieldValue, ReportName, ReportID)


' Designed for early bind, set reference to PDFCreator
Dim pdfjob
Dim sPDFName
Dim sPDFPath


'/// Change the output file name here! ///
sPDFName = FieldValue
sPDFPath = "C:\PDFReports"


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
' in VBScript use WScript.Sleep(20)
Loop
pdfjob.cClose
Set pdfjob = Nothing


End Sub



Thanks in advance for your help!


Regards,

Daniël.

4 Replies
thomas_skariah
Contributor III

Re: Macro to split pdf is not working anymore(pdfcreator 2.5.2)

Hi Daniel,

I also facing similar issue, when I try to open the macro edit module the script starts executing automatically.

Regards,

Tom

Not applicable

Re: Macro to split pdf is not working anymore(pdfcreator 2.5.2)

Hi Tom,

That's strange...

In my case the macro won't run at all. When I click on 'run' it opens the edit module..

Regards,

Daniël.

Re: Macro to split pdf is not working anymore(pdfcreator 2.5.2)

I would try to locate the problem by commenting some parts, for example the pdf-call to see if the selections-loop worked. Quite helpful for it is also to implement some msgbox-statements to find the point where the routine stopped. Further I would check if anything has changed within the application (field renamed, report deleted), by qlikview (a different release) and by the OS and the printer itself, for example removing or updating the printer or another default printer is set or ... Did you try if you could print with this printer manually?

- Marcus

james227
New Contributor

Re: Macro to split pdf is not working anymore(pdfcreator 2.5.2)

It has to do with the upgrade.  PDF creator 2.0+ has different command lines.

CreateObject("PDFCreatorBeta.JobQueue")  for the job queue

and CreateObject("PDFCreatorBeta.PDFCreatorObj") for the obj.

It functions slightly differently than the older versions as the queue is a separate object now.  You can either revert back to the older version and your macro will work or modify your current macro with the new commands.

Community Browser