Hi,
I am using this macro to merge two pdf:s. Each pdf have page numbers, and the merged file keeps the original page numbers.
I want to make a new numbering for the whole new (merged) pdf.
Any clues?
Sub MergePdf()
'inspired by VBA A2Z youtube:
Dim Aapp As Acrobat.AcroApp
Dim PDF As Acrobat.AcroPDDoc
Dim SourcePDF As Acrobat.AcroPDDoc
Dim WB As Workbook
Dim WS As Worksheet
Dim Folder As String
Dim FileCompanySv, FileCompanyEn, FileFundEn, FileFundSv As String
Dim Path As String
Dim i As Integer
Dim PDF_pages, SourcePDF_pages As Long
Set WB = Workbooks("All.xlsm")
Set WS = Sheets("FileNamesSe")
Set Aapp = CreateObject("AcroExch.App")
Set PDF = CreateObject("AcroExch.PDDoc")
Set SourcePDF = CreateObject("AcroExch.PDDoc")
WB.Activate
i = 3
Path = WS.Cells(1, 2).Value
FileFundSv = WS.Cells(i, 1).Value
FileCompanySv = WS.Cells(1, 3).Value
Aapp.Show
PDF.Open (Path & FileFundSv)
PDF_pages = PDF.GetNumPages() - 1
SourcePDF.Open (Path & FileCompanySv)
SourcePDF_pages = SourcePDF.GetNumPages()
If PDF.InsertPages(PDF_pages, SourcePDF, 0, SourcePDF.GetNumPages(), True) = False Then
Debug.Print "Failed to insert the page"
End If
If PDF.Save(PDSaveFull, "C:\Users\towe03\Test\KOOOOLLLA.pdf") = False Then
Debug.Print "Failed to save"
Else
Debug.Print "Doc Saved"
End If
PDF.Close
SourcePDF.Close
Set Aapp = Nothing
Set PDF = Nothing
Set SourcePDF = Nothing
End Sub
I am using this macro to merge two pdf:s. Each pdf have page numbers, and the merged file keeps the original page numbers.
I want to make a new numbering for the whole new (merged) pdf.
Any clues?
Sub MergePdf()
'inspired by VBA A2Z youtube:
Dim Aapp As Acrobat.AcroApp
Dim PDF As Acrobat.AcroPDDoc
Dim SourcePDF As Acrobat.AcroPDDoc
Dim WB As Workbook
Dim WS As Worksheet
Dim Folder As String
Dim FileCompanySv, FileCompanyEn, FileFundEn, FileFundSv As String
Dim Path As String
Dim i As Integer
Dim PDF_pages, SourcePDF_pages As Long
Set WB = Workbooks("All.xlsm")
Set WS = Sheets("FileNamesSe")
Set Aapp = CreateObject("AcroExch.App")
Set PDF = CreateObject("AcroExch.PDDoc")
Set SourcePDF = CreateObject("AcroExch.PDDoc")
WB.Activate
i = 3
Path = WS.Cells(1, 2).Value
FileFundSv = WS.Cells(i, 1).Value
FileCompanySv = WS.Cells(1, 3).Value
Aapp.Show
PDF.Open (Path & FileFundSv)
PDF_pages = PDF.GetNumPages() - 1
SourcePDF.Open (Path & FileCompanySv)
SourcePDF_pages = SourcePDF.GetNumPages()
If PDF.InsertPages(PDF_pages, SourcePDF, 0, SourcePDF.GetNumPages(), True) = False Then
Debug.Print "Failed to insert the page"
End If
If PDF.Save(PDSaveFull, "C:\Users\towe03\Test\KOOOOLLLA.pdf") = False Then
Debug.Print "Failed to save"
Else
Debug.Print "Doc Saved"
End If
PDF.Close
SourcePDF.Close
Set Aapp = Nothing
Set PDF = Nothing
Set SourcePDF = Nothing
End Sub