Print Report to PDF with open source PDFCreator

    Sub Print

      PrintPDF("Your File Name","RP01")

    End Sub


    Function PrintPDF(NamePDF, qvObject)

      Dim vPath

      vPath= "C:\"

      Set PDFCreator = CreateObject("PDFCreator.clsPDFCreator")

      PDFCreator.cStart ("/NoProcessingAtStartup")


      PDFCreator.cOption("UseAutosave") = 1 ' Enable autosave

        PDFCreator.cOption("UseAutosaveDirectory") = 1 ' Use a specific save directory

      'Comment this line if you already set on PDFCreator a directory where you wont to save a PDFfile

      'PDFCreator.cOption("AutosaveDirectory") =vPath  ' Set autosave directory from variable  'ActiveDocument.getVariable("TempPath").GetContent.String ' Set autosave directory from set analisis variable

        PDFCreator.cOption("AutosaveFormat") = 0 '  0=PDF, 1=PNG, 2=JPG, 3=BMP, 4=PCX, 5=TIFF, 6=PS, 7= EPS, 8=ASCII

        PDFCreator.cOption("AutosaveFilename") = NamePDF ' & ".pdf"' set the filename, optionally you can get the Caption of the object and use it as Filename

        PDFCreator.cPrinterStop = False          'printer enabled


      ActiveDocument.PrintDocReport qvObject, "PDFCreator"    'print


      ActiveDocument.GetApplication.Sleep 5000    'stop my macro for 5 sec, its time is need to save a PDF

      PDFCreator.cClearCache()    'clear cache


    end function