4 Replies Latest reply: Jul 25, 2017 10:15 AM by James P RSS

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

    Daniel Vischjager



      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()


      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"


      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

      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)
      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)
      Set pdfjob = Nothing

      End Sub

      Thanks in advance for your help!