Results 1 to 5 of 5
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    Print in a loop

    Hello,



    I have a table (tblMyTable) with a field(pdfLink) that has the links to files I'd like to print based on another field (Print) that is checked (true/false). Can someone help me with the code? I'd presume I need to create a record set and loop through the records?

    Table Name: tblMyTable
    Field1: pdfLink
    Field2: print

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Are you looking to automatically print out the file, or review the file first and set printing options from within the Adobe application?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by Micron View Post
    Are you looking to automatically print out the file, or review the file first and set printing options from within the Adobe application?
    I'm looking to print automatically without previewing them.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Easier to open a series or open one and print. I can do both using the Shell function, but I don't think it's very slick or reliable. It would require certain parameters to be stable, such as the location of Adobe Reader, how long it takes to open and how long it takes to send a document to the print queue. If you're looking for a Lincoln, I'm offering a Toyota Yaris, I think.

    Code:
    Function OpenPrintPdf()
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim sql As String, sfile As String, strAcrobat As String
    Dim RetVal
    
    sql = "SELECT tblMyTable.pdfLink FROM tblMyTable WHERE [Print]=True;"
    strAcrobat = "C:\Program Files\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
    
    Set db = CurrentDb
    Set rs = db.OpenRecordset(sql)
    rs.MoveFirst
    Do While Not rs.EOF
         sfile = rs.Fields(0)
         RetVal = Shell(strAcrobat & " /P " & Chr(34) & sfile & Chr(34), 0)
         Pause (3)
         SendKeys "^p~", True
         Pause (3)
         rs.MoveNext
    Loop
    SendKeys "^q", True 'key combo to close Adobe Reader
    
    End Function
    Code:
    Private Sub Pause(intSecs As Integer)
    Dim Start As Variant
    Start = Timer
    Do While Timer < Start + intSecs
           DoEvents
    Loop
    End Sub
    I think automation would be more elegant and perhaps stable, but I've never automated Adobe. I'm presuming Adobe is registered on the system. A small point, but Print is not a word I would use in my table.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Thank you, Micro for taking the time. I've chosen another route. When I have a chance, I will post it for others to learn.

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

Similar Threads

  1. Replies: 12
    Last Post: 06-05-2015, 04:27 PM
  2. Replies: 13
    Last Post: 08-20-2014, 09:17 AM
  3. Replies: 5
    Last Post: 07-29-2014, 01:05 PM
  4. Replies: 17
    Last Post: 04-07-2014, 07:48 PM
  5. Replies: 3
    Last Post: 03-10-2013, 07:04 AM

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