Solved

Print PDF file outside of access database

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

867 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

22 Experts available now in Live!

Get 1:1 Help Now