Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open PDF file, Print then Close

Status
Not open for further replies.

Zeroanarchy

Technical User
Jun 11, 2001
630
0
0
AU
Does anyone know of a way of opening a pdf, printing and then closing acrobat?

So far I can get it to open the file then print but it stays open..


Code:
Private Declare Function ShellExecute Lib "shell32" _
  Alias "ShellExecuteA" _
 (ByVal hwnd As Long, _
  ByVal lpOperation As String, _
  ByVal lpFile As String, _
  ByVal lpParameters As String, _
  ByVal lpDirectory As String, _
  ByVal nShowCmd As Long) As Long

Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWDEFAULT As Long = 10
Private Const SE_ERR_NOASSOC As Long = 31



Private Sub lblName_Click()
Dim strPath3 As String
strPath3 = [Text1].Value
Call ShellExecute(0&, "print", strPath3, 0&, 0&, SW_HIDE)
End sub

Cheers

[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.

 
anyone?

[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.

 

Unfortunately, adobe is like that. It likes to stay in memory.

Over the past few months there has been enough code posted in this forum to get you started on the following possible solution.

Check printer jobs and make sure there is none
Do your shellexecute API to print
Wait for printer jobs to increment (search for printer jobs)
Wait for printer jobs to decrement (back to zero)
Kill adobe (search for shell and wait, and for kill application)

Good Luck

 
Ok Thanks vb5prgrmr, I found a way of making it work. There was not enough in this forum to make it work I had to go else where.



Cheers


[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.

 
Zeroanarchy

And your answer was ..... ?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Yeh what was your answer to this as I am interested in knowing.
 
I thought I got it to work and if I put in a bit more effort it would. I have got it to the stage where it will open print wait 2sec then close but that still is not good enough as it will not close unless the printer is off or has an error. It will retain the print job and close but not if it has to print it straight away.

Cheers

[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.

 
There is a way to do this by cycling through the running processes and compare the name to "Acrobat.exe". Use the windows API, CreateToolhelp32Snapshot, to create your running process list and then just cycle through them using GetProgramName to get the name and ProcessNext to move through the list of processes. Then use the CloseHandle method to kill the process.

Kophjager
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top