Skip to main content
airnan
Participant
January 24, 2019
Question

VBA PrintPagesSilent parameters

  • January 24, 2019
  • 1 reply
  • 1596 views

Good morning,

I need to modify a macro in VBA so that it prints pages 2 to the end of a PDF document.

The problem is how to specify the last page of the document, which varies with every document the macro has to process.

Can you please explain how to do it? Maybe it requires getting the lenght of the PDF document first, which I don't know exactly how to do it.

This is the macro code so far, which would only print from page 2 (first parameter) up to page 3 (second parameter):

                ad_ac_doc.Open ("DocName.pdf"), ""

                pri_err = ad_ac_doc.PrintPagesSilent(1, 2, 2, 0, 0)

                ad_ac_doc.Close 1

                ad_pd_doc.Close

                Set ad_pd_doc = Nothing

                Set ad_ac_doc = Nothing

                Set ad_app = Nothing

Thanks and best regards.

This topic has been closed for replies.

1 reply

BarlaeDC
Community Expert
Community Expert
January 24, 2019

Hi,

Could you not just call GetPDDoc and then use the GetNumPages call?

Something like ( just of the top of my head, so not tested.)

ad_pd_doc = ad_ac_doc.GetPDDoc();

// because PDF docs start at page 0.

numPages = ad_pd_doc.GetNumPages() - 1

pri_err = ad_ac_doc(PrintPageSilent ( 1, numPages, 2, 0, 0)

hope this helps

Malcolm