Results 1 to 15 of 15

Thread: PDF File (2003)

  1. #1
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PDF File (2003)

    Hi,

    I would like to send report as PDF format as email attachment. I did search all the forms regarding the PDF. I am confuse since there's two way to do it, one is use link, another one is use print function. Can you advice which one is best to me, or there's something else is better? I have Access 2003 & Adobe Acrobat 7.0 Professional.

    Thanks

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

    Re: PDF File (2003)

    I'm not sure what you mean by link vs print.

    A link to a PDF file will only work in one of the following situations:

    a) You send the e-mail only to people within your local area network (LAN), and you make the PDF file available on a shared network folder, or on the local intranet.
    [img]/forums/images/smilies/cool.gif[/img] You make the PDF available on a web page that the recipients can visit.

    Otherwise, you must send the PDF file itself as attachment.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PDF File (2003)

    Thanks. Now I am understood how link works is.

    For my situation, I should use print to PDF. Below is my current process to send report of PDF format as email attachment:

    1) Open the report
    2) Select Adobat printer
    3) Select email after PDF open
    4) Change back to my default printer.

    Is anyway to set step 2-4 automatic? I found a sample file regarding automatic change print to Adobat then change back to default printer from the website, but it doesn't work when I click "Print PDF." Please check the attachment.

    Thanks

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

    Re: PDF File (2003)

    I don't have Acrobat myself, so I cannot test anything, but much of the code in the database you attached is not needed in Access 2002 or higher. You can simply set a printer by using

    Application.Printer = "printer name"

    You can find several examples of sending PDF files in this forum.

  5. #5
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PDF File (2003)

    Thanks.

    I did search in this forum by typing sending PDF files, but I didn't find any useful information. Can you provide me some examples or detail of printing PDF file.

    Thanks a lot.

    Regards

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

    Re: PDF File (2003)

    Set PDF filename: set the caption of the report, or see <post:=322,094>post 322,094</post:>.

    Send e-mail with attachment: <post:=324,559>post 324,559</post:>

    I cannot help you with creating PDF files, I have no experience with that.

  7. #7
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PDF File (2003)

    Hi Hans,

    Thanks! After I reviewed post 322,094 and use code provided by Francois, please see below. Everthing is works except the path of PDF folders. Where I should put the path in the code?
    Please review the attached code provide by Francois.

    "This program is tested on a win xp and I don't know if it will run on other windows version.
    In the attachment you'll find to txt files.
    Extract them and copy the content of each of the files in a different new module. Save the modules but don't use the name RunReportAsPDF as this is the name of the sub and a sub may not have the same name as a module.
    For each report you want to run, use an instruction as follow :
    Call RunReportAsPDF("ReportName","PrinterName")
    Replace ReportName with the name of your report.
    Replace Printer Name with the printer name you find in the registry when the Adobe Distiller is set as default.
    To find this out :
    Set the adobe distiller as default printer.
    Go to Start , Run and type regedit.
    Navigate to the key HKEY_CURRENT_USERSoftwareMicrosoftWIndows NTCurrentVersionWindows
    Look in the right pane form the key Device and note the string. (On my pc it's : Acrobat Distiller,winspool,Ne01: )
    This is the text you have to use as PrinterName.
    Close the regedit.
    Set you usual printer as default back."""


    Thanks

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

    Re: PDF File (2003)

    Immediately above the lines

    ' Run the report
    DoCmd.OpenReport ...

    insert these lines:

    ' Folder where PDF file will be written
    Const sPDFPath = "C:myapparchive"
    ' Set file name
    SetPDFFileNames PDFPath & strReportName & ".pdf"

  9. #9
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PDF File (2003)

    Image cropped to 640 pixels wide by HansV

    Thanks.

    I insert the lines but error message pops up. Please see below:

    Thanks

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

    Re: PDF File (2003)

    I apologize, that is my error. It should have been

    SetPDFFileNames sPDFPath & strReportName & ".pdf"

    (sPDFPath instead of PDFPath)

  11. #11
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PDF File (2003)

    Hi Hans,

    Still have error message, please see below: Thanks

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

    Re: PDF File (2003)

    As I have told you, I cannot try out these things for myself, since I don't have Acrobat. So it is all "air code". If you look through your code, you'll find what it should have been instead of SetPDFFileNames.

  13. #13
    4 Star Lounger
    Join Date
    Feb 2006
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PDF File (2003)

    Thanks

    I fixed it. Now it works.

  14. #14
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: PDF File (2003)

    Hans,

    I find this to be easier to create .PDF files when creating them from Access reports. Your thoughts?



    Dim strDefaultPrinter As String

    'Get the default printer being used
    strDefaultPrinter = Application.Printer.DeviceName

    ' Switch the Default Printer to print to Adobe
    Set Application.Printer = Application.Printers("Adobe PDF")

    'Create the PDF File / Print to PDF
    DoCmd.OpenReport "R_EmployeeByDept"

    'Reset the printer to the original default printer
    Set Application.Printer = Application.Printers(strDefaultPrinter)
    Regards,

    Gary
    (It's been a while!)

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

    Re: PDF File (2003)

    As I have said more than once, I don't have any experience with creating PDF files in code, but your code looks simple.

Posting Permissions

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