How to Print a PDF in Excel VBA?

jacksa2

New Member
Joined
Dec 10, 2015
Messages
4
Hello All,

I've been working on being able to print a PDF file from Excel VBA but having a rough time with it. Every example I can find is very different than the next and none have worked.

Concept is fairly straight forward.
-User inputs file name.
-Look for PDF with that name in specified folder
-Print it
-Close PDF viewer if it opens

I have already made code that works for word and excel file types, but cant figure out PDF.
I am working with Excel 2010 on windows 7, with Adobe reader 11.0 in the standard C:\Program Files (x86)\Adobe\Reader 11.0 location.

Any help would be greatly appreciated! Thanks
 
This is a really old post and not one with code I use much.
No, you can't specify a page - ShellExecute doesn't allow you to set parameters like that when using the PRINT command.
As for closing the file - you would have to find and Kill the process (Adobe). There is code out there for that, but I am not comfortable posting such code that interferes with the OS (especially untested)
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
This is a really old post and not one with code I use much.
No, you can't specify a page - ShellExecute doesn't allow you to set parameters like that when using the PRINT command.
As for closing the file - you would have to find and Kill the process (Adobe). There is code out there for that, but I am not comfortable posting such code that interferes with the OS (especially untested)
Thank you very much for your explanation. Instead of printing pdf, I just want to open the pdf file. What changes should I make in the code?
 
Upvote 0
In the ShellExecute call change the "Print" to "Open"
Hi Starl
is it possible to specific save folder in order to bypass the prompt popup screen ask for save file?
Thank you in advance.
 
Upvote 0
I don't know. As stated earlier, I don't use ShellExecute very much.
You might have better luck if you posted a new question - it will be more prominent and others may look at it.
 
Upvote 0

Forum statistics

Threads
1,215,232
Messages
6,123,765
Members
449,121
Latest member
Vamshi 8143

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top