Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print PDF file outside of access database

Posted on 2010-09-16
2
Medium Priority
?
678 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
  • 2
2 Comments
 
LVL 7

Accepted Solution

by:
Usama Foad earned 1000 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 7

Expert Comment

by:Usama Foad
ID: 33771720
Is that work or not?
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

971 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