ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Page Numbers to PDF (https://www.excelbanter.com/excel-programming/440943-add-page-numbers-pdf.html)

swami

Add Page Numbers to PDF
 
I am looking to progammatically add page numbers to a PDF using VBA. I create
a multi-page PDF using various Excel reports. The PDF then needs to be
numbered sequentially. I have been able to research and find code to add a
watermark to the PDF, but, no luck on page numbering. I am using Excel 2007
and Acrobat 9.

Code Example:
Sub WatermarkPDF()

Dim bolResult As Boolean
Dim pdfDoc1 As AcroPDDoc
Dim jsObj As Object

Set pdfDoc1 = CreateObject("AcroExch.PDDoc")

If pdfDoc1.Open("C:\Test\Ranges\Reports\Custom_Merged .pdf") Then
Set jsObj = pdfDoc1.GetJSObject
jsObj.addWatermarkFromText ("Confidential")
End If

savepgnumfile = pdfDoc1.Save(1,
"C:\Test\Ranges\Reports\Custom_Merged_Watermark.pd f")

pdfDoc1.Close

Set jsObj = Nothing
Set pdfDoc1 = Nothing

End Sub


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com