Results 1 to 7 of 7

Thread: Printing to PDF

  1. #1
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Unanswered: Printing to PDF

    I'm using the defaultptr.zip code by Ken Getz and everything is working fine except one problem. The code is the following (using the other modules from the defaultprt.zip)

    ChangeToAcrobat
    ChangePdfFileName Me!PDFLocation & "\" & "StaffDirectoryByLastName.pdf"
    DoCmd.OpenReport "rptcolumns", acViewNormal
    ResetDefaultPrinter

    When I run this, it will change the default printer to the Adobe PDF writer (i.e. Function ChangeToAcrobat). The goal is to automatically print the report to the pdf file specified (in the ChangePDFFileName.) Problem is though on the docmd.OpenReport "rptColumns", acViewNormal - I keep getting a prompt to save the pdf file (it seems to ignore the ChangePDFFileName command.). I must be doing something wrong even though I'm using the code exactly as specified. Has anyone used the code by Ken Getz to print to a pdf file and been able to avoid having it always prompt for the pdf file name/location upon issuing the docmd.OpenReport "MyReportName"? I have several reports which I want to automatically print to a pdf file without a prompt on each report for the pdf filename to save the report to.
    Last edited by pkstormy; 10-26-07 at 11:32.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Based on this post: http://www.dbforums.com/showpost.php...35&postcount=1

    It seems as though I'm in for some problems (I have the new Adobe PDF driver on my computer which doesn't apparently use Win.ini). Dang Adobe with their changing of drivers and making it difficult to come up with some standard vba code which works in all situations. Problem is that we have several users which have different versions of a PDF Writer (including some shareware PDF creators on some users computers.)

    I'd like to come up with some standard vba code where if the user has "any" PDF creating software on their computer, I can utilize it to automatically create a PDF file from several reports but this does not sound possible. Issues I'm coming across are that sometimes the driver is called: "Adobe PDF Writer", other times it's called: "Acrobat PDF Writer", or "Acrobat Distiller" or "Adobe PDF", etc...etc...

    If anyone has this kind of code which can recognize any PDF driver - please respond. Since my experience with PDF file creations is limited, I'm not sure if anyone else has experienced issues like these. I'm hoping someone has found a way to recognize if "any" PDF Creator is installed and a way you've found it possible to automatically create a PDF file from a report. User's cannot re-install to another PDF driver if they already have one and it sounds like this might not be doable.

    It would be nice to come up with some code to work on all computers which have "a" PDF Writer driver. Having users install another (or newer) PDF driver is not an option.
    Last edited by pkstormy; 10-26-07 at 14:03.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Feb 2007
    Posts
    348
    Paul,
    I haven't used that code nor even seen it but I came across an article that mentions that you need to download the Adobe SDK and:

    In general, it requires making the Adobe PDF Writer the default printer in Windows and then setting keys in the registry which are associated with the Adobe Acrobat install:
    "bDocInfo" needs to be set to "0"
    "PDFFileName" sb set to


    It sounds like the code you have makes it so you don't have to keep adobe as your default but you may still need to do those modifications to avoid the print dialog. I'm afraid that solution may fail your second criteria of working on Adobe clones though.

    I hope I'm not telling you stuff you already know.

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks for the response Starkmann.

    God I hate this working with PDF stuff! The problem is everyone at this place has a different PDF driver installed (some are freeware, some are old Acrobat versions, etc...etc...)

    I'm pulling my hairs out trying to come up with some code to handle any PDF driver someone could have on their machine. So far, I've got a listbox which shows the different printers/drivers installed on their computer and they select the PDF driver to use to print the reports to a pdf file. One of the problems is I can't get the simple: Dim Prn as Printer to debug (won't recognize "Printer").

    I hate Adobe and PDF files!
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I have recently worked with PDFs and Adobe, and from what I have done you have to open the report in Preview mode in order to change the printer it will print to.

    I used some code that I found by Googling. The code I used can be found by Googling RunReportAsPDF. This code will save the report name in the registry. The value is used the next time Adobe is opened and then reset by Adobe.

    Let me know if this helps or not. I have working code that is based on the code I found but I modified it for my purposes.

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks DCKunkle! I will take a look.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I found some good info using the google keyword of RunReportAsPDF I didn't find before. Now to parse through it.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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