Copy link to clipboard
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)
Set ad_pd_doc = Nothing
Set ad_ac_doc = Nothing
Set ad_app = Nothing
Thanks and best regards.
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