Results 1 to 5 of 5
  1. #1
    kassem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    22

    How to save report as PDF in certain folder

    Hi all,



    I want to save the current report open as a pdf in a designated folder but am not sure how.

    I found the following code that saves it as a pdf but u have to select the location, how can i automate this.

    Code:
    DoCmd.OutputTo acOutputReport, "R_RptByRevdDate", acFormatPDF, , , , , acExportQualityPrint
    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    When you TYPE the "DoCmd.OutputTo" command, VBA will show you all the parameters you need to fill in.
    (it wont work by pasting the code)

    But the next param after format is filename...

    Code:
    DoCmd.OutputTo acOutputReport, "R_RptByRevdDate", acFormatPDF, "c:\my folder\MyRpt.pdf"

  3. #3
    kassem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    22
    Thanks a million, One last question. Instead of MyRpt can I change the code somehow to use the name stored in a string variable i created called NameOfReport.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    yes, variables work too.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You just need to concatenate the string.

    Declare your string variable
    Dim NameOfReport as string

    initialize
    NameOfReport = ""

    Set its value
    NameOfReport = Me.ControlName

    Include the variable by concatenating it in your string
    Code:
    DoCmd.OutputTo acOutputReport, "R_RptByRevdDate", acFormatPDF, "c:\my folder\" & NameOfReport & ".pdf"

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Save file as a different user to a network folder
    By rstruck in forum Programming
    Replies: 4
    Last Post: 05-10-2014, 04:53 PM
  2. Save report to a folder
    By Gilgamesh in forum Programming
    Replies: 2
    Last Post: 12-23-2012, 07:25 PM
  3. Replies: 2
    Last Post: 04-26-2012, 02:55 AM
  4. save folder to another directory
    By focosi in forum Programming
    Replies: 7
    Last Post: 08-30-2011, 07:22 AM
  5. Replies: 9
    Last Post: 05-30-2011, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums