Solved

Print PDF file outside of access database

Posted on 2010-09-16
2
673 Views
Last Modified: 2012-05-10
I have a question maybe someone has come across before.  I have a print button on a form in access that I need to print all of the PDF files in a certain folder.  When you click on the button it should automatically print all the PDF's in that folder to the default printer.  Anyone know how to do this?
0
Comment
Question by:ine2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
UsamaFoad earned 250 total points
ID: 33695357
Try this code, but you must have adobe reader.
Private Sub Command1_Click()
On Error GoTo Command1_Click_Error
Dim iNoOfFiles As Integer
Dim iCounter As Integer
Dim sFilePath As String

sFilePath = "C:\temp" ' Replace with your folder

With Application.FileSearch
    .NewSearch
    .LookIn = sFilePath
    .FileName = "*.pdf" 'replace with "*.txt" to find txt files
                        ', "*.doc" for documents .. etc Or with "*.*" for all files type
    .SearchSubFolders = False
    .Execute
    iNoOfFiles = .FoundFiles.Count
    For iCounter = 1 To iNoOfFiles
        Debug.Print .FoundFiles(iCounter)
        ' Print The file with Adobe Reader 9
        ' if you have another version or your adobe reader instaled
        ' in another path change the following path to your "acrord32.exe" file
        ' Replace "vbHide" with vbMinimizedFocus, vbMaximizedFocus OR vbNormalFocus if you
        ' wont Adobe appear during printing
        Shell """C:\Program Files\Adobe\Reader 9.0\Reader\acrord32.exe"" /h /p """ + .FoundFiles(iCounter) + """", vbHide
    Next iCounter

End With
   On Error GoTo 0
   Exit Sub

Command1_Click_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command1_Click"
End Sub

Open in new window

0
 
LVL 6

Expert Comment

by:UsamaFoad
ID: 33771720
Is that work or not?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question