Results 1 to 15 of 15
  1. #1
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access to PDF (Access2003)

    I found code that I really like and would like to use...however at the end I am getting an empty .ps file

    Here is something I really like:

    Dim objPDF as PdfDistiller,strRepName as String,strCustomRepName as String, strPath as String, intRetvalue as Integer

    strRepName="Inventory"

    strPath="C:PDFFILEs"

    strCustomRepName="Inventory_Report__Month_May"

    Set Application.Printer=Application.Printers("Adobe PDF")

    set objPDF = New PdfDistiller

    intRetValue=objPDF.FileToPDF (strRepName,strPath & strCustomFileName & ".pdf","")
    ******************************************
    Sub Generate_PS(strReportName as String) ' Generates a post script file

    DoCmd.OpenReport strReportName,AcViewPreview
    SendKeys "%Fp%l~" & strpath & strReport & ".ps~",True
    DoCmd.Close acReport,strReportName

    End Sub
    *******************************************

    I am however getting an empty Distiller file.

    In my adaptation of this code - it looks as follows


    strRecruitersNames = !NAME_DISPLAY
    ReportName = FileName & " " & strRecruitersNames & "_" & FileDateFormat
    ReportLocation = "C:My Documents"

    DoCmd.OpenReport ReportName:="Candidate_Report", View:=acViewPreview, WhereCondition:="Name_Display = " & Chr(34) & strRecruitersNames & Chr(34)

    SendKeys "%Fp%l~" & strpath & strReport & ".ps~",True
    DoCmd.Close acReport,strReportName


    Set Application.Printer=Application.Printers("Adobe PDF")

    set objPDF = New PdfDistiller

    intRetValue=objPDF.FileToPDF (ReportName, ReportLocation & ".pdf", "")
    ************************************************** ******************************


    So my Access Report is open and I am going to the line SendKeys "%Fp%l~" & strpath & strReport & ".ps~",True
    and I see the flash of the directory and print...and no file gets created.

    Do you see where I am failing?

    Thanks

  2. #2
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    I found the thread in another forum where they have a perfect simple code for Excel to the PDF.

    http://www.tek-tips.com/viewthread.cfm?qid=416162

    what we need is the Active Printer (property we don't have in Access) be set to Distiller.

    Anyone, please?

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access to PDF (Access2003)

    You can do something like this:

    DoCmd.OpenReport ReportName:="Candidate_Report", ...
    Reports("Candidate_Report").Printer = Application.Printers("Adobe Distiller")

    Replace "Adobe Distiller" with the actual name of the Distiller printer.

  4. #4
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    It is great, no one could figure it out and you did it again, Hans, thanks!

    However I am stil in a jam.
    I am using Adobe 8 Professional.
    Somehow we do not have Distiller anymore.
    Everything was coded previously is failing and searching on Internet for 2 days I found that I am not alone.
    I found the article with name:
    Print Access Report to PDF V6 or V7, using VBA - is this a secret?
    Where person struggling with the issue and posting pretty good code he used in the past but it is not working no more.

    I am also asking - is this a secret? Which is funny, right?

    I don't know where else to go, thanks to all and please, I am open to an ideas.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access to PDF (Access2003)

    If you have Adobe Acrobat, you can usually print to the "Adobe PDF" printer - check your printer list for the exact name.

  6. #6
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Access to PDF (Access2003)

    I use the ConvertReportToPDF function I got from http://www.lebans.com. Easy to implement.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access to PDF (Access2003)

    I already pointed MS_Fan to ReportToPDF in <post:=733,173>post 733,173</post:> but apparently (s)he doesn't want to use it.

  8. #8
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    Gentleman,
    I appreciate your help and determination and I want to apologize to Hans - I did not mean to ignore your suggestion - it is just I use to be able to do this in a snap and Leban's code was so scarily complicated...
    However I have adapted it to run my Reports and output into PDF and it seems working just great!!!
    Thanks for that.

    One thing is with saving actual PDF file in certain directory:

    With rstRS
    Do While Not .EOF
    strRecruitersNames = !NAME_DISPLAY
    ReportName = "Candidate_Report"
    ReportLocation = "C:My Documents"

    DoCmd.OpenReport ReportName:="Candidate_Report", View:=acViewPreview, WhereCondition:="Name_Display = " & Chr(34) & strRecruitersNames & Chr(34)

    ReportNewName = FileName & " " & strRecruitersNames & "_" & FileDateFormat

    blRet = ConvertReportToPDF(ReportName, vbNullString, ReportNewName & ".PDF", True)

    DoCmd.Close acReport, "Candidate_Report"

    DoCmd.Save
    .MoveNext

    Loop

    End With
    ************************************************** *********************

    After I am closing Access Report - I have PDF is still open.

    I need to Save it in C: somewhere and close it.

    The rest is working and I have to thanks you again and again - both of you, Hans and Mark!
    Have a great day!

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access to PDF (Access2003)

    Stephen Lebans' code is complicated but you don't have to worry about that - you don't have to understand it. You only need to use the ConvertReportToPDF function.

    You can specify that the PDF file created by the function isn't opened by adding False for the StartPDFViewer argument:

    blRet = ConvertReportToPDF(ReportName, vbNullString, ReportNewName & ".PDF", True, False)

  10. #10
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    I've realized that and I've took a chance...after you basically made me do it :-) thanks

    I did changed False to the True and now it is opening PDF.

    However now if I change it back - how do I save it to the C:?

    I don't see any place to enter directory.

    Thanks

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access to PDF (Access2003)

    You can include the path in the 3rd argument, where you now have

    ReportNewName & ".PDF"

    You could change this to

    "C:" & ReportNewName & ".PDF"

    Modify as needed.

  12. #12
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    Hm! That easy, huh?

    Thanks so much and I hope I am done with questions!

    Yep and it is 'she':-)

  13. #13
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    I've jinxed myself!

    Somewhere in the code

    Public Property Let DialogTitle(vNewValue As String)
    'assign object's DialogTitle property
    sDialogTitle = vNewValue
    End Property

    it goes to the place below

    clsDialog.Filter = "PDF (*.PDF)" & Chr$(0) & "*.PDF" & Chr$(0)
    'clsDialog.Filter = clsDialog.Filter & "Gif (*.GIF)" & Chr$(0) & "*.GIF" & Chr$(0)
    'clsDialog.Filter = "ALL (*.*)" & Chr$(0) & "*.*" & Chr$(0)
    clsDialog.hDC = 0
    clsDialog.MaxFileSize = 256
    clsDialog.Max = 256
    clsDialog.FileTitle = vbNullString
    clsDialog.DialogTitle = "Please Select a path and Enter a Name for the PDF File"
    clsDialog.InitDir = vbNullString
    clsDialog.DefaultExt = vbNullString

    it has "Please Select a path and Enter a Name for the PDF File" and window pops up waiting for me to select where to output the file.

    I need to bypass this or give it a name and the location which I thought I need to do later...

    However in a mean time I am entering name of the file and it gets saved into directory but I am receiving a message about file bienf corrupted and try again...
    but file is saved and fine and sitting where it is suppose to be.

    Was I suppose to not to copy some of the modules?
    I took it all!

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access to PDF (Access2003)

    Please take a look at the description of the arguments for ConvertReportToPDF in the code (in the modReportToPDF module).
    If you don't want the Save As dialog to be displayed, you should specify False for the 4th argument ShowSaveFileDialog.

    blRet = ConvertReportToPDF(ReportName, vbNullString, "C:" & ReportNewName & ".PDF", False, False)

  15. #15
    5 Star Lounger
    Join Date
    Jan 2005
    Posts
    614
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access to PDF (Access2003)

    WORKS WORKS WORKS!
    THANKS THANKS THANKS!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •