Shell command to close Acrobat

LB79

Registered User.
Local time
Today, 23:41
Joined
Oct 26, 2007
Messages
505
Hi all,

I'm using Shell Command to select PDF files via Access and print them (code below)

Code:
Shell "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe /p /h " & MySQL

This is great BUT when the file has printed it leaves Acrobat open.
Can anyone tell me the She Command to exit Acrobat?


Also, how can I print a PDF file and specify the printer and the duplex option?

Thanks
 
Last edited:
With your shell command you could then use a Delay Time and then use the SendKey to close the programme down.

Shown below is an Example of using Shell command to Open Paint up and after delay it is copying and pasting values from Excel, but the principal is there. If you do a search on sendkeys you will find a solution.

Sub CopyToPaint()
Dim vetral As String
Range("D4").Copy
vetral = Shell("msPaint.exe", vbNormalFocus)
Delay 3
Application.SendKeys "%ep"
End Sub
Private Sub Delay(sec)
Dim newHour ' = Hour(Now())
Dim newMinute ' = Minute(Now())
Dim newSecond ' = Second(Now())
Dim waitTime ' = Delay time in Secs
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + sec
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
End Sub
 
1. You can't use Shell to open a program and expect to be able to close it. Shell only executes the command and releases. There is nothing around to be able to control anything afterwards.

2. I am enclosing code (.bas file which you can import to your database by going to the VBA window and right click in the area where the different modules are listed and select IMPORT FILE) which we use to print out to PDF's as well as to create them and do bookmarks and to merge multiple PDF's to a single PDF.
 

Attachments

Users who are viewing this thread

Back
Top Bottom