How do I set path and name of report printed to virtual printer?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raddrummer
    New Member
    • Oct 2007
    • 26

    #1

    How do I set path and name of report printed to virtual printer?

    Hi,

    I've installed a virtual printer that allows me to save access reports as .pdf files. Within Access (using VBA) I'm using the DoCmd.OpenRepor t action to send the file to be printed. When I do this a pop up box appears asking me for the path and name of the file to be saved.

    Since I'm trying to automate this process, how do I set these parameters programatically in VBA?

    Below is an excerpt of the code I have so far.

    Code:
    Function CutReports()
    Dim rsContacts As New ADODB.Recordset
    Dim RPTPAN As Access.Report
    Dim strName As String
    
    rsContacts.ActiveConnection = CurrentProject.Connection
    rsContacts.Open "QRY12MoReviewNewMIPNo"
    
    Do While Not rsContacts.EOF
    
    'Send data for this active record to Report and save as PAN.pdf
    strName = rsContacts!EEFullName 
    DoCmd.OpenReport "RPTPAN", acViewNormal, , "[EEFullName] = '" & strName & "'"
    ‘Here is where I’m stuck.  I need to dictate where and under what name to save the file.
    
    DoCmd.Close acReport, "RPTPAN", acSaveNo
    
    
    'Move to the next person in the recordset
    rsContacts.MoveNext
    
    Loop
  • DonRayner
    Recognized Expert Contributor
    • Sep 2008
    • 489

    #2
    You could try the SendKeys function. I don't use it myself but I played with it a bit and this is how I got it to work. I had to use the forms timer to delay the sendkey function to give the save dialog enough time to open.

    Code:
    DoCmd.OpenReport "RPTPAN", acViewNormal, , "[EEFullName] = '" & strName & "'"
    Me.TimerInterval = 500
    
    Private Sub Form_Timer()
    SendKeys "DocumentName.pdf" & "{enter}", True
    Me.TimerInterval = 0
    End Sub

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Ingenious solution Don :)

      The simple answer is that there is no programmatic access to it as such. As far as Access (therefore your code) is aware, it is sending a report to a printer. The PDF builder part of the driver you're sending it to is entirely non-standard.

      Having said that, it is possible that the provider of the software has released a separate API that you could use to control it directly. This depends on who the provider is of course. It may be worth a look (Google, or contact them directly).

      Good luck with your project.

      Comment

      • raddrummer
        New Member
        • Oct 2007
        • 26

        #4
        Will do. Thanks to all for checking it out.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          No worries.

          Good luck with your project :)

          Comment

          Working...