Hi,
I have two PDF files, "PDF_1" and "PDF_2".
I want to write VBA code that merges PDF_1 with PDF_2, then saves PDF_2 (which now should be a product of both files)
Here is the code that I have been able to gather:
It does absolutely nothing for some odd reason.
---------------------------------
Option Explicit
Public Function Test()
Dim PDF_1_Name, File_Path, PDF_2_Name, File_Ext As String
Dim AcroExchApp As Acrobat.CAcroApp
Dim AcroExchPDDoc As Acrobat.CAcroPDDoc
Dim AcroExchInsertPDDoc As Acrobat.CAcroPDDoc
Dim iNumberOfPagesToInsert, iLastPage As Integer
Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
File_Ext = ".pdf"
File_Path = "C:\Documents and Settings\Administrator\Desktop\Attachments"
PDF_2_Name = "" & File_Path & "\" & "PDF_2" & "" & File_Ext & ""
PDF_1_Name = "C:\Documents and Settings\Administrator\Desktop\Attachments\Originals\PDF_1.pdf"
AcroExchPDDoc.Open (PDF_2_Name)
AcroExchApp.Show
iLastPage = AcroExchPDDoc.GetNumPages()
Set AcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")
AcroExchInsertPDDoc.Open (PDF_1_Name)
iNumberOfPagesToInsert = AcroExchInsertPDDoc.GetNumPages
AcroExchPDDoc.InsertPages iLastPage, AcroExchInsertPDDoc, 0, iNumberOfPagesToInsert, True
AcroExchInsertPDDoc.Close
AcroExchPDDoc.Save &H1, "PDF_2_Name"
AcroExchPDDoc.Close
AcroExchApp.Exit
End Function
----------------------------------
Any help would be greatly appreciated.
Thanks in Advance!
Regards
FGP
I have two PDF files, "PDF_1" and "PDF_2".
I want to write VBA code that merges PDF_1 with PDF_2, then saves PDF_2 (which now should be a product of both files)
Here is the code that I have been able to gather:
It does absolutely nothing for some odd reason.
---------------------------------
Option Explicit
Public Function Test()
Dim PDF_1_Name, File_Path, PDF_2_Name, File_Ext As String
Dim AcroExchApp As Acrobat.CAcroApp
Dim AcroExchPDDoc As Acrobat.CAcroPDDoc
Dim AcroExchInsertPDDoc As Acrobat.CAcroPDDoc
Dim iNumberOfPagesToInsert, iLastPage As Integer
Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")
File_Ext = ".pdf"
File_Path = "C:\Documents and Settings\Administrator\Desktop\Attachments"
PDF_2_Name = "" & File_Path & "\" & "PDF_2" & "" & File_Ext & ""
PDF_1_Name = "C:\Documents and Settings\Administrator\Desktop\Attachments\Originals\PDF_1.pdf"
AcroExchPDDoc.Open (PDF_2_Name)
AcroExchApp.Show
iLastPage = AcroExchPDDoc.GetNumPages()
Set AcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")
AcroExchInsertPDDoc.Open (PDF_1_Name)
iNumberOfPagesToInsert = AcroExchInsertPDDoc.GetNumPages
AcroExchPDDoc.InsertPages iLastPage, AcroExchInsertPDDoc, 0, iNumberOfPagesToInsert, True
AcroExchInsertPDDoc.Close
AcroExchPDDoc.Save &H1, "PDF_2_Name"
AcroExchPDDoc.Close
AcroExchApp.Exit
End Function
----------------------------------
Any help would be greatly appreciated.
Thanks in Advance!
Regards
FGP