Results 1 to 6 of 6
  1. #1
    BP2E is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    4

    Talking Splitting one large PDF report into separate PDF by Doctor name

    Hello,
    I currently run a monthly report which details productivity by doctor. The Access report separates each doctor but prints as one 300+page PDF, which then is manually split into individual PDF's. How can this task be automated? I've scoured google looking for an answer but to no avail.
    As you can tell I am quite a beginner when it comes to excel. Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by June7 View Post
    If you are going to create an ADODB recordset object and you are using newer versions of Access (I am guessing 2013 and newer), you will need to create a reference to the 'Microsoft ActiveX Data Objects X.X Library'. Perhaps it would be easier to use DAO.

  4. #4
    BP2E is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2015
    Posts
    4
    Thank you for the quick answer. When I copy and paste the link provided it doesn't work.
    What parts of the code shown below would need to be modified: The query field name which dictates where to separate is "Doctor Name"
    In the meantime I will do a basic VBA 101 course. ie what to do after clicking on database tools-- VB-- and removing the "Option Compare Database"
    Thanks again.
    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Set cn = CurrentProject.Connection
    Set rs = New ADODB.Recordset

    rs.Open "SELECT LabNum FROM Submit;", cn, adOpenStatic, adLockPessimistic
    While Not rs.EOF
    DoCmd.OpenReport "LabReport", acViewPreview, , "LabNum='" & rs!LABNUM & "'"
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, "drive:\path\" & rs!LABNUM & ".pdf", True
    DoCmd.Close acReport, "LabReport", acSaveNo
    'kill Adobe Acrobat so I don't have thousands of open pdf documents
    Dim objWMIService As Object, objProcList As Object, objProcess As Object
    Set objWMIService = GetObject("winmgmts:")
    Set objProcList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'acrobat.exe'")
    For Each objProcess In objProcList
    objProcess.Terminate (0)
    Next
    rs.MoveNext

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Copy/paste what link? Apparently you have seen the sample code. But did you read the part about not really needing the "kill" code?

    Do not remove "Option Compare Database".

    Should add below that line "Option Compare".

    Substitute where needed your actual names for report, table, field, and filepath.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by BP2E View Post
    Hello,
    I currently run a monthly report which details productivity by doctor. The Access report separates each doctor but prints as one 300+page PDF, which then is manually split into individual PDF's. How can this task be automated? I've scoured google looking for an answer but to no avail.
    As you can tell I am quite a beginner when it comes to excel. Thanks!
    Ys it is possible to do. It will require a recordset that has a unique list of each Dr that needs a report.

    I have created this working example that might help: Batch Printing and Save As PDF

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

Similar Threads

  1. Replies: 6
    Last Post: 10-22-2015, 06:12 AM
  2. Replies: 1
    Last Post: 07-23-2015, 05:11 AM
  3. Replies: 7
    Last Post: 10-31-2012, 04:58 PM
  4. Converting large report to PDF
    By jgelpi16 in forum Reports
    Replies: 2
    Last Post: 07-05-2011, 12:09 PM
  5. Splitting a field to separate fields
    By Petefured in forum Programming
    Replies: 8
    Last Post: 06-08-2009, 04:11 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