More Help on Printing an External File within Access VBA (2003)

mkacos
mkacos used Ask the Experts™
on
This is a good solution (http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27056617.html) but I also need to know how to select the actual printer is is going to.  I have tons of TIF files that I need to convert to PDF (thanks MSFT for dropping tif).  I have purchased a printer driver from CutePDF that I use in my Access VBA code that will print anything to a PDF.

In Access VBA, I can set the printer to Auto PDF (it shows as an installed printer) then I can print an Access report to Auto PDF.  I have tried the following with the API call with no luck: ShellExecute(Application.hWndAccessApp, "print /D:Auto PDF", WrkFileName, "", "", 0).  I receive "Unable to initialize device Auto PDF" then I replace that with CPWPT185: (which is trhe port assigned to this print device) and I get the same error.

Is there a way to direct the API to a specific printer that is installed on the system?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:

Author

Commented:
Boag2000 - I am trying to print an exteral file to a printer not a report.  
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
Ooops, sorry...

I say a way to do this once...

An expert should be along with the code shrortly
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
Commented:
I ended up setting the AutoPDF printer to the default printer on the computer.  Then I figured out that MSPVIEW (MSFT Document Imaging) has an un-documented command line command (-p) that will print from the command line.  I used the following code to make this happen from within VBA.

Shell Chr(34) & "mspview" & Chr(34) & " -p " & Chr(34) & Application.FileSearch.FoundFiles(i) & Chr(34), vbMaximizedFocus

THis worked great.




Author

Commented:
This is a work around not a real solution.
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
<This is a work around not a real solution.>
If a "Workarond" fixes your issue then it IS Solution, AFAIC.
So congrats on finding your own solution.
;-)

(Just be aware that many machines do not have MSFT Document Imaging installed)

JeffCoachman

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial