How to open pdf from VBA

D

daniel

Hi All,

I am doing a task with pdf files and got some questions:

1. How to print pdf file by using VBA code without open it? I mean do
it in the back end and user does not see it. I have tried some code
but not working. Can anyone please give me some example?

2. I have got two pages in a pdf, but I want to print it into one
page. (I have got large printer.) Is it possible to do it in the code?

Thanks in advance!

Cheers
Danel
 
A

Albert D. Kallal

daniel said:
Hi All,

I am doing a task with pdf files and got some questions:

1. How to print pdf file by using VBA code without open it?

Try:

CreateObject("Shell.Application").Namespace(0).ParseName("c:\mypdf\myDoc.pdf").InvokeVerb
("&Print")

The above works for any file in windows that supports the right click->print
option. so, the above should work for printing word or excel files also. In
all of these cases, you need the appropriate software installed.
2. I have got two pages in a pdf, but I want to print it into one
page. (I have got large printer.) Is it possible to do it in the code?

I not really sure the above is an access feature, or even a pdf feature. If
you manually click on the pdf file, is there options to print 2 pages on one
page? This likely could be an feature of the particular printer and I not
sure it can be done from ms-access. However, someone else might chime in to
tell me/us other wise...
 
J

James A. Fortune

Albert said:
I not really sure the above is an access feature, or even a pdf feature. If
you manually click on the pdf file, is there options to print 2 pages on one
page? This likely could be an feature of the particular printer and I not
sure it can be done from ms-access. However, someone else might chime in to
tell me/us other wise...

That feature is commonly known as 2-up. In general, n-up for printing n
pages per PDF/PostScript output sheet. It's typically a feature of the
software program used to display the PDF or of a PDF software toolkit.
BTW, if you have control of the PDF creation process, then it shouldn't
be too difficult to roll your own n-up by applying a scaling linear
transformation operator to each page from one PDF file as input and
outputting the results to an n-up PDF file. Searching for 2-up might
turn up something useful and ready-made. Good values for n include 2,
4, 6, 8, 9, etc. Except for 2, prime numbers are generally poor choices
for n :).

James A. Fortune
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top