Thanks Chris!

---------- Original Message ----------
From: Chris Davis <chr...@actongate.co.uk>
To: profoxt...@leafe.com
Subject: RE: Pringing PDFs via ShellExecute from VFP
Date: Fri, 2 Jul 2021 09:43:35 +0000

Hi Philip

I had the same problem recently and switched with success to 

http://www.columbia.edu/~em36/pdftoprinter.html

as sometimes we found adobe would leave itself open so any checks to see if it 
was still running couldn't be relied on.

Then using the following ShellExecute code ... you will notice my method on the 
form agcheckexe("pdftoprinter.exe"), I have included that code as well as this 
basically loops until any previous instances have finished before it launches 
again for the next PDF you want to queue up ...

&& PDF PRINT METHOD
LPARAMETERS lcfilename
lcfilename=ALLTRIM(TRANSFORM(lcfilename))

declare INTEGER ShellExecute in shell32 INTEGER handle, STRING @ oper, ;
STRING @ ifile, STRING @ iparam, STRING @ ipath, INTEGER showcmd

lcfile="c:\pdfprinter\pdftoprinter.exe"
lcpath=""

lcparam=["]+lcfilename+["]

DO WHILE thisform.agcheckexe("pdftoprinter.exe")
ENDDO

shellexecute(0,"open",lcfile,lcparam,lcpath,1)
=========================

&& AGCHECKEXE METHOD
LPARAMETERS tcName, tlTerminate
LOCAL loLocator, loWMI, loProcesses, loProcess, llIsRunning
loLocator       = CREATEOBJECT('WBEMScripting.SWBEMLocator')
loWMI           = loLocator.ConnectServer() 
loWMI.Security_.ImpersonationLevel = 3                  && Impersonate

loProcesses     = loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE Name = '] 
+ tcName + ['])
llIsRunning = .F.
IF loProcesses.Count > 0
        FOR EACH loProcess in loProcesses
                llIsRunning = .T.
                IF tlTerminate
                        loProcess.Terminate(0)
                ENDIF
        ENDFOR
ENDIF
RETURN llIsRunning
============================

Regards

Chris

-----Original Message-----
From: ProfoxTech <profoxtech-boun...@leafe.com> On Behalf Of Philip Borkholder
Sent: 01 July 2021 20:55
To: profoxt...@leafe.com
Subject: Pringing PDFs via ShellExecute from VFP

Hi all,

I am currently printing VFP reports in sequence, then using ShellExecute to 
print PDFs via their default program (Adobe DC).
I am trying to keep each print job in sequence so they come out in the tray 
together:
Example:

WO #1
Drawings for WO #1 (PDF via ShellExecute)

WO #2
Drawings for WO #1 (PDF via ShellExecute)

etc.

What I'm running into is sometimes WO#2 prints out before WO#1's PDF prints 
from Adobe DC.

Does anyone have experience in using a Windows API to see if Adobe has printed 
the PDF before I can continue printing my next VFP form?

Thanks

Philip B
Bison Tech Plus

[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: https://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: https://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: https://leafe.com/archives
This message: 
https://leafe.com/archives/byMID/20210702.085218.245...@webmail03.dca.untd.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to