Saving Report to PDF without using DLL OCX

Discussion in 'Access VBA Modules' started by Rick Brandt, May 27, 2010.

  1. Rick Brandt

    Rick Brandt Guest

    Daniel Pineault wrote:

    > Lebans Rpt2PDF is great and easy to distribute! Can`t get any easier!!!
    > Trust me I tried many ways (Adobe Acrobat, PDFCreator,...) and Lebans is
    > the
    > best by Far. Actually on a side note, Acrobat does generate certain lines
    > from reports into the PDFs and yet Lebans does it perfectly.
    >
    > Furthermore, I could be wrong, but to use the 'clsPDFCreator' class, do
    > you not first have to have installed PDFCreator on each pc thus installing
    > DLLs and much more!?


    The problem for many with Lebans' wonderful tool (which I use myself) is
    that Access 2010 is going to break it. So for many it won't survive the
    long haul.
     
    Rick Brandt, May 27, 2010
    #1
    1. Advertisements

  2. Rick Brandt

    Which1 Guest

    I found this code on the internet and I am trying to get it to work but I am
    stumped.
    As far as I can tell it seems to work fine until i get to this piece of code:

    Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))

    The clspdf.cOutputFilename is always empty. I also get a dialog box stating
    "This action can't be compleated because the other application is busy.
    Choose switch to to activate the busy application and correct the problem."
    But I can't select switch to because the app locks up. I have to go into
    taskmanager to end the Adobe exe process.

    I also had to comment out the handle error because the
    modPDFPrinter_PrintPDF function can't be found.

    I don't want to have to rely on dlls or ocx files.

    Any help would be appreciated
    ***** Begin Code*****
    Public Function PrinttoPDF(ByVal RptName As String, Optional
    sAutoSaveDirectory As String, Optional sAutoSaveFileName As String) As Boolean


    'initialise
    On Error GoTo err_Error
    Dim clsPDF As PDFCreator.clsPDFCreator 'Initialise the PDF class
    Dim strDefaultPrinter As String
    Dim strOutputFileName As String
    Dim strSaveDirectory As String
    Dim i As Long

    'set the success variable to true here but it will be set to
    'false if the function fails at any point
    PrinttoPDF = True

    Set clsPDF = New clsPDFCreator

    With clsPDF
    ..cStart "/NoProcessingAtStartup"
    ..cOption("UseAutosave") = 1 '1 = True, 0 = False

    If sAutoSaveDirectory = "" Then
    ..cOption("UseAutosaveDirectory") = 0
    Else
    ..cOption("UseAutosaveDirectory") = 1
    ..cOption("AutosaveDirectory") = sAutoSaveDirectory
    End If

    If sAutoSaveFileName = "" Then
    ..cOption("AutosaveFileName") = RptName
    Else
    ..cOption("AutosaveFileName") = sAutoSaveFileName
    End If

    ..cOption("AutosaveFormat") = 0 '0 = PDF
    strDefaultPrinter = .cDefaultPrinter
    ..cDefaultPrinter = "PDFCreator"
    ..cClearCache
    Sleep 1
    DoCmd.OpenReport RptName, acViewPreview
    ..cPrinterStop = False
    End With

    i = 0

    Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))
    i = i + 1
    Sleep 500
    Loop
    strOutputFileName = clsPDF.cOutputFilename

    With clsPDF
    ..cDefaultPrinter = strDefaultPrinter

    Sleep 200
    ..cClose
    End With

    If strOutputFileName = "" Then
    MsgBox "Creating pdf file." & vbCrLf & vbCrLf & _
    "An error has occured: Time is up!", vbExclamation + vbSystemModal
    PrinttoPDF = False
    'Call HandleError("Report " & sAutoSaveFileName & " did not print",
    "modPDFPrinter_PrintPDF")
    End If

    'error handler and exit
    err_Exit:
    Set clsPDF = Nothing
    Exit Function
    err_Error:
    PrinttoPDF = False
    MsgBox Err.Description
    'Call HandleError(Err.Description, "modPDFPrinter_PrintPDF")
    Resume err_Exit
    Resume

    End Function
     
    Which1, May 27, 2010
    #2
    1. Advertisements

  3. Do you have the free MS Office pdf addin? If so, you can just use outputto
    function, like so:

    DoCmd.OutputTo acOutputReport, "Cheese Cakes", acFormatPDF, "c:\cheesecake.
    pdf", False, "", 0, acExportQualityPrint

    Which1 wrote:
    >I found this code on the internet and I am trying to get it to work but I am
    >stumped.
    >As far as I can tell it seems to work fine until i get to this piece of code:
    >
    >Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))
    >
    >The clspdf.cOutputFilename is always empty. I also get a dialog box stating
    >"This action can't be compleated because the other application is busy.
    >Choose switch to to activate the busy application and correct the problem."
    >But I can't select switch to because the app locks up. I have to go into
    >taskmanager to end the Adobe exe process.
    >
    >I also had to comment out the handle error because the
    >modPDFPrinter_PrintPDF function can't be found.
    >
    >I don't want to have to rely on dlls or ocx files.
    >
    >Any help would be appreciated
    >***** Begin Code*****
    >Public Function PrinttoPDF(ByVal RptName As String, Optional
    >sAutoSaveDirectory As String, Optional sAutoSaveFileName As String) As Boolean
    >
    >'initialise
    >On Error GoTo err_Error
    >Dim clsPDF As PDFCreator.clsPDFCreator 'Initialise the PDF class
    >Dim strDefaultPrinter As String
    >Dim strOutputFileName As String
    >Dim strSaveDirectory As String
    >Dim i As Long
    >
    >'set the success variable to true here but it will be set to
    >'false if the function fails at any point
    >PrinttoPDF = True
    >
    >Set clsPDF = New clsPDFCreator
    >
    >With clsPDF
    >.cStart "/NoProcessingAtStartup"
    >.cOption("UseAutosave") = 1 '1 = True, 0 = False
    >
    >If sAutoSaveDirectory = "" Then
    >.cOption("UseAutosaveDirectory") = 0
    >Else
    >.cOption("UseAutosaveDirectory") = 1
    >.cOption("AutosaveDirectory") = sAutoSaveDirectory
    >End If
    >
    >If sAutoSaveFileName = "" Then
    >.cOption("AutosaveFileName") = RptName
    >Else
    >.cOption("AutosaveFileName") = sAutoSaveFileName
    >End If
    >
    >.cOption("AutosaveFormat") = 0 '0 = PDF
    >strDefaultPrinter = .cDefaultPrinter
    >.cDefaultPrinter = "PDFCreator"
    >.cClearCache
    >Sleep 1
    >DoCmd.OpenReport RptName, acViewPreview
    >.cPrinterStop = False
    >End With
    >
    >i = 0
    >
    >Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))
    >i = i + 1
    >Sleep 500
    >Loop
    >strOutputFileName = clsPDF.cOutputFilename
    >
    >With clsPDF
    >.cDefaultPrinter = strDefaultPrinter
    >
    >Sleep 200
    >.cClose
    >End With
    >
    >If strOutputFileName = "" Then
    > MsgBox "Creating pdf file." & vbCrLf & vbCrLf & _
    > "An error has occured: Time is up!", vbExclamation + vbSystemModal
    >PrinttoPDF = False
    >'Call HandleError("Report " & sAutoSaveFileName & " did not print",
    >"modPDFPrinter_PrintPDF")
    >End If
    >
    >'error handler and exit
    >err_Exit:
    >Set clsPDF = Nothing
    >Exit Function
    >err_Error:
    >PrinttoPDF = False
    >MsgBox Err.Description
    >'Call HandleError(Err.Description, "modPDFPrinter_PrintPDF")
    >Resume err_Exit
    >Resume
    >
    >End Function


    --

     
    WebJunkey via AccessMonster.com, May 27, 2010
    #3
  4. Rick Brandt

    Jack Leach Guest

    > The problem for many with Lebans' wonderful tool (which I use myself) is
    > that Access 2010 is going to break it.


    Sometimes evolution really does suck. I'm going to go crazy when I get to
    the point where I can no longer stay with 2003.

    I wonder if 2010 will include new and ridiculous features such as the
    normalization-breaking "mulit-value fields" that came with '07 (and not to
    mention that wonderful ribbon that everyone has so much fun with!!). Way to
    go MS!!!

    Sorry, just a little rant...

    --
    Jack Leach
    www.tristatemachine.com

    "I haven't failed, I've found ten thousand ways that don't work."
    -Thomas Edison (1847-1931)



    "Rick Brandt" wrote:

    > Daniel Pineault wrote:
    >
    > > Lebans Rpt2PDF is great and easy to distribute! Can`t get any easier!!!
    > > Trust me I tried many ways (Adobe Acrobat, PDFCreator,...) and Lebans is
    > > the
    > > best by Far. Actually on a side note, Acrobat does generate certain lines
    > > from reports into the PDFs and yet Lebans does it perfectly.
    > >
    > > Furthermore, I could be wrong, but to use the 'clsPDFCreator' class, do
    > > you not first have to have installed PDFCreator on each pc thus installing
    > > DLLs and much more!?

    >
    > The problem for many with Lebans' wonderful tool (which I use myself) is
    > that Access 2010 is going to break it. So for many it won't survive the
    > long haul.
    >
    > .
    >
     
    Jack Leach, May 28, 2010
    #4
  5. Rick Brandt

    Which1 Guest

    Is that pdf addin for Access 2003 or is only for Access 2007?

    "WebJunkey via AccessMonster.com" wrote:

    > Do you have the free MS Office pdf addin? If so, you can just use outputto
    > function, like so:
    >
    > DoCmd.OutputTo acOutputReport, "Cheese Cakes", acFormatPDF, "c:\cheesecake.
    > pdf", False, "", 0, acExportQualityPrint
    >
    > Which1 wrote:
    > >I found this code on the internet and I am trying to get it to work but I am
    > >stumped.
    > >As far as I can tell it seems to work fine until i get to this piece of code:
    > >
    > >Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))
    > >
    > >The clspdf.cOutputFilename is always empty. I also get a dialog box stating
    > >"This action can't be compleated because the other application is busy.
    > >Choose switch to to activate the busy application and correct the problem."
    > >But I can't select switch to because the app locks up. I have to go into
    > >taskmanager to end the Adobe exe process.
    > >
    > >I also had to comment out the handle error because the
    > >modPDFPrinter_PrintPDF function can't be found.
    > >
    > >I don't want to have to rely on dlls or ocx files.
    > >
    > >Any help would be appreciated
    > >***** Begin Code*****
    > >Public Function PrinttoPDF(ByVal RptName As String, Optional
    > >sAutoSaveDirectory As String, Optional sAutoSaveFileName As String) As Boolean
    > >
    > >'initialise
    > >On Error GoTo err_Error
    > >Dim clsPDF As PDFCreator.clsPDFCreator 'Initialise the PDF class
    > >Dim strDefaultPrinter As String
    > >Dim strOutputFileName As String
    > >Dim strSaveDirectory As String
    > >Dim i As Long
    > >
    > >'set the success variable to true here but it will be set to
    > >'false if the function fails at any point
    > >PrinttoPDF = True
    > >
    > >Set clsPDF = New clsPDFCreator
    > >
    > >With clsPDF
    > >.cStart "/NoProcessingAtStartup"
    > >.cOption("UseAutosave") = 1 '1 = True, 0 = False
    > >
    > >If sAutoSaveDirectory = "" Then
    > >.cOption("UseAutosaveDirectory") = 0
    > >Else
    > >.cOption("UseAutosaveDirectory") = 1
    > >.cOption("AutosaveDirectory") = sAutoSaveDirectory
    > >End If
    > >
    > >If sAutoSaveFileName = "" Then
    > >.cOption("AutosaveFileName") = RptName
    > >Else
    > >.cOption("AutosaveFileName") = sAutoSaveFileName
    > >End If
    > >
    > >.cOption("AutosaveFormat") = 0 '0 = PDF
    > >strDefaultPrinter = .cDefaultPrinter
    > >.cDefaultPrinter = "PDFCreator"
    > >.cClearCache
    > >Sleep 1
    > >DoCmd.OpenReport RptName, acViewPreview
    > >.cPrinterStop = False
    > >End With
    > >
    > >i = 0
    > >
    > >Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))
    > >i = i + 1
    > >Sleep 500
    > >Loop
    > >strOutputFileName = clsPDF.cOutputFilename
    > >
    > >With clsPDF
    > >.cDefaultPrinter = strDefaultPrinter
    > >
    > >Sleep 200
    > >.cClose
    > >End With
    > >
    > >If strOutputFileName = "" Then
    > > MsgBox "Creating pdf file." & vbCrLf & vbCrLf & _
    > > "An error has occured: Time is up!", vbExclamation + vbSystemModal
    > >PrinttoPDF = False
    > >'Call HandleError("Report " & sAutoSaveFileName & " did not print",
    > >"modPDFPrinter_PrintPDF")
    > >End If
    > >
    > >'error handler and exit
    > >err_Exit:
    > >Set clsPDF = Nothing
    > >Exit Function
    > >err_Error:
    > >PrinttoPDF = False
    > >MsgBox Err.Description
    > >'Call HandleError(Err.Description, "modPDFPrinter_PrintPDF")
    > >Resume err_Exit
    > >Resume
    > >
    > >End Function

    >
    > --

    >
    >
    > .
    >
     
    Which1, May 30, 2010
    #5
  6. There is always the "PDF" printer.

    I use the free "Primo PDF" print driver. If you have a report that will
    print to a normal printer, then just print to the PDF "printer". It will work
    for any version of Access. Nothing to add to your Access project.


    --
    HTH
    ---
    Steve S
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)


    "Jack Leach" wrote:

    > > The problem for many with Lebans' wonderful tool (which I use myself) is
    > > that Access 2010 is going to break it.

    >
    > Sometimes evolution really does suck. I'm going to go crazy when I get to
    > the point where I can no longer stay with 2003.
    >
    > I wonder if 2010 will include new and ridiculous features such as the
    > normalization-breaking "mulit-value fields" that came with '07 (and not to
    > mention that wonderful ribbon that everyone has so much fun with!!). Way to
    > go MS!!!
    >
    > Sorry, just a little rant...
    >
    > --
    > Jack Leach
    > www.tristatemachine.com
    >
    > "I haven't failed, I've found ten thousand ways that don't work."
    > -Thomas Edison (1847-1931)
    >
    >
    >
    > "Rick Brandt" wrote:
    >
    > > Daniel Pineault wrote:
    > >
    > > > Lebans Rpt2PDF is great and easy to distribute! Can`t get any easier!!!
    > > > Trust me I tried many ways (Adobe Acrobat, PDFCreator,...) and Lebans is
    > > > the
    > > > best by Far. Actually on a side note, Acrobat does generate certain lines
    > > > from reports into the PDFs and yet Lebans does it perfectly.
    > > >
    > > > Furthermore, I could be wrong, but to use the 'clsPDFCreator' class, do
    > > > you not first have to have installed PDFCreator on each pc thus installing
    > > > DLLs and much more!?

    > >
    > > The problem for many with Lebans' wonderful tool (which I use myself) is
    > > that Access 2010 is going to break it. So for many it won't survive the
    > > long haul.
    > >
    > > .
    > >
     
    Steve Sanford, Jun 1, 2010
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Hoegiesrocker

    I need the dll file " IncrediUtils.dll" How?

    Hoegiesrocker, Sep 11, 2004, in forum: Access VBA Modules
    Replies:
    2
    Views:
    84
    Dawson
    Sep 16, 2004
  2. sjlevine34
    Replies:
    3
    Views:
    228
    Tony_VBACoder
    Mar 10, 2006
  3. Reliza
    Replies:
    4
    Views:
    314
    Reliza
    Jan 6, 2006
  4. Stephen Bull

    Calling 16-bit DLL MSAU200.DLL

    Stephen Bull, Mar 2, 2006, in forum: Access VBA Modules
    Replies:
    1
    Views:
    220
    Allen Browne
    Mar 2, 2006
  5. Tonto

    using ocx

    Tonto, Feb 9, 2007, in forum: Access VBA Modules
    Replies:
    0
    Views:
    78
    Tonto
    Feb 9, 2007
  6. Amp
    Replies:
    5
    Views:
    121
    Stuart McCall
    Nov 19, 2008
  7. mccallen60

    Saving Access03 Report to multiple pdf's

    mccallen60, Mar 10, 2009, in forum: Access VBA Modules
    Replies:
    6
    Views:
    64
    dymondjack
    Mar 16, 2009
  8. Steve Sanford

    RE: Saving Report to PDF without using DLL OCX

    Steve Sanford, May 27, 2010, in forum: Access VBA Modules
    Replies:
    2
    Views:
    196
    Daniel Pineault
    May 27, 2010
Loading...