I am trying to open three pdf files in order to merge them. We create a series of files on a monthly basis that are all identified by "ticker".
I have three source files:
RootDoc = Root file, produced monthly, variable filename: "[variable ticker] + [static RootDoc append].pdf"
DefDoc = Static file, variable filename, "[variable ticker] + [static DefDoc append].pdf"
NotesDoc = One file, does not change, must be included in all docs.
I'm stuck on how to merge appropriately under the following conditions:
1) The number of ticker-labeled files in the folder each month will vary.
2) The RootDoc and DefDoc of the same ticker must be paired together as they contain ticker-specific information. The tickers will match on both files, but will vary in character length from one set of files to the next.
3) I have a footer format saved in Adobe that must be applied to all docs. (this is not necessary but would be nice to have, I can do this outside of VBA if necessary)
Here's what I have so far, with notations commented out for clarity:
With Application
.DisplayAlerts = False
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Dim Filename, Pathname, PRODname, Defname As String
Dim RootDoc, NotesDoc, DefDoc As AcroPDDoc
Dim stp1, stp2, stp3, mergefile As Variant
Pathname = "H:\apps\xp\Desktop\PROD CHECK\Expanded LT"
'PRODname = "*[static RootDoc append].pdf"
Filename = Dir(Pathname & "\" & PRODname)
'Defname = "*[static DefDoc append].pdf"
Set RootDoc = CreateObject("AcroExch.PDDoc")
Set NotesDoc = CreateObject("AcroExch.PDDoc")
Set DefDoc = CreateObject("AcroExch.PDDoc")
'stp1 = NotesDoc.Open("[unchanging file name and location]")
Do While Filename <> ""
'stp2 = RootDoc.Open(Pathname & "\" & Filename)
'stp3 = DefDoc.Open("[location]" & "\" & Defname)
'mergefile = RootDoc.InsertPages([I want to insert all of DefDoc into RootDoc after page 0])
'mergefile = RootDoc.InsertPages([I want to insert all of NotesDoc after the last page of RootDoc])
DefDoc.Close SaveChanges:=False
'RootDoc = [Apply Saved Footer]
RootDoc.Close SaveChanges:=True
Filename = Dir()
Loop
With Application
.DisplayAlerts = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With