Solved

Print PDF file outside of access database

Posted on 2010-09-16
2
664 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 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

#Citrix #Citrix Netscaler #HTTP Compression #Load Balance
If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now