using excel vba to print a pdf file

T

Tom Ogilvy

Here is one approach:

Sub Tester2a()
Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" & _
" c:\toc1\amcr37-4.pdf", 1
' the following prints the document
Application.SendKeys "^p~", False
End Sub


or if you have .pdf associated with acrobat reader:


Private Sub CommandButton1_Click()
Shell "Start.exe ""D:\My Documents\sm569_Jan2001\tute6.pdf"""
Application.SendKeys "^p~", False
End Sub
 
G

Guest

Thanks Tom
--
Helping Is always a good thing


Tom Ogilvy said:
Here is one approach:

Sub Tester2a()
Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" & _
" c:\toc1\amcr37-4.pdf", 1
' the following prints the document
Application.SendKeys "^p~", False
End Sub


or if you have .pdf associated with acrobat reader:


Private Sub CommandButton1_Click()
Shell "Start.exe ""D:\My Documents\sm569_Jan2001\tute6.pdf"""
Application.SendKeys "^p~", False
End Sub




--

Regards,

Tom Ogilvy
 
G

Guest

Tom,

I'm receiving a file not found error, even though I know the pathe is correct
is it because the file is located on a share network drive?

here is the code i have

Sub Tester2a()
Path_PDF = Range("Access_Path")
Prn_File = Range("Access_File")
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe" & Path_PDF &
"\" & Prn_File & ", 1"
' the following prints the document
Application.SendKeys "^p~", False
End Sub
 
D

Dave Peterson

Tom had a space between acrord32.exe and the file name. You'll want one, too.

Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & _
Path_PDF & "\" & Prn_File & ", 1"
 
G

Guest

Dave,
Thanks that was driving me crazy

Now how can I get it to print multiple pdf's, tried looping it but only one
prints
 
D

Dave Peterson

Maybe...

Sub Tester2a()
dim myCell as range
dim Path_PDF as string
dim Prn_File_Rng as range

Path_PDF = Range("Access_Path")
set Prn_File_Rng = Range("Access_File_Rng")

for each mycell in prn_file_rng.cells
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " _
& Path_PDF & "\" & mycell.value & ", 1"
Application.SendKeys "^p~", False
next mycell
End Sub

Maybe you can send ctrl-Q to exit the Reader after it prints, too???

(Untested, uncompiled)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top