VBA syntax to print

This seems simple, but I can't find it online.  I have files in multiple formats (HTML, XML, JPG, TXT, PDF), that I want to print to the the Adobe PDF printer.  Searching and downloading the files is done using VBA so I have to use that for the printing action as well.  I've been trying multiple variations, specifically PrintOut, but that seems specific to Access and/or Excel:  Basically, I'm looking for the syntax to send any file, regardless of format, to a printer of my choosing.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
you could install irfanview tool, and pilot it to print:
"i_view32.exe c:\testpics\*.jpg /print=printing_name"

not sure if that tool can print all of the file formats you want, and in case you will need to find the relevant tool that can do so from command line, and adjust the command line accordingly.

via the shellexecute to run that command:

hope this helps
You will need to use the Windows Shell object.  This is a one-line version of a print command.  If you needed to do a lot of these, you would probably instantiate an object variable instead of doing a CreateObject() for every print.
CreateObject("Shell.Application").Namespace(0).ParseName("C:\Users\AikiMark\Downloads\Smart Podiums.pdf").InvokeVerb("Print")

Open in new window

Here is a scripting guy example of code that uses more of the Windows Shell features to print all the files in a folder.

It may also be possible to use the ShellExecute API.

If you know the programs associated with the file types, you might use the wscript.shell object to run the application and print the file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Phish_HeadAuthor Commented:
Thanks, aikimark, on first blush, that's working.  Anywhere in that line I can specify printer?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
with ShellExecuteAPI you can use the Print option and specify the printing in lpParameters:

note: to use print verb as suggested, the "print" method needs to be registered for the file types ...
I think that the Windows Shell object allows you to specify the default printer.  You would save the current printer name, change the default printer to the one you want, do your printing, and then change the default printer back to the original.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.