![]() |
|
#4
|
||||
|
||||
|
Try the following. It will produce a PDF in the same directory as the Word document and will prompt you to select the 'other' pdfs to include with the one from the current Word doc.
Note that you need to include a reference to Acrobat (under Tools > References) Code:
Public Sub SaveToPDF()
Dim sFilePath As String
ActiveDocument.Save
sFilePath = ActiveDocument.FullName & ".pdf"
ActiveDocument.SaveAs2 FileName:=sFilePath, FileFormat:=wdFormatPDF
MergePDFs sFilePath
End Sub
Sub MergePDFs(sPDF As String)
' Reference required: "VBE - Tools - References - Acrobat"
Dim a As Variant, i As Long, n As Long, ni As Long, p As String
Dim AcroApp As New Acrobat.AcroApp
Dim fd As Office.FileDialog
Dim oPDF As Acrobat.CAcroPDDoc
Dim oNextPDF As Acrobat.CAcroPDDoc
Set oPDF = CreateObject("AcroExch.PDDoc")
oPDF.Open sPDF
Set oNextPDF = CreateObject("AcroExch.PDDoc")
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = True
.Title = "Select the files to merge."
.Filters.Clear
.Filters.Add "Adobe Acrobat Pro", "*.pdf"
If .Show = -1 Then
For i = 1 To fd.SelectedItems.Count
n = oPDF.GetNumPages()
oNextPDF.Open .SelectedItems(i)
ni = oNextPDF.GetNumPages()
oPDF.InsertPages nInsertPageAfter:=n - 1, iPDDocSource:=oNextPDF, _
lStartPage:=1, lNumPages:=ni, lInsertFlags:=True
oNextPDF.Close
Next i
End If
End With
oPDF.Save nType:=1, sFullPath:=sPDF
oPDF.Close
Set oPDF = Nothing
Set oNextPDF = Nothing
' Quit Acrobat application
AcroApp.Exit
Set AcroApp = Nothing
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Tags |
| acrobat, combine documents, pdf |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Combine multiple word files into 1 document and add section breaks | svo | Word VBA | 3 | 08-05-2015 03:05 AM |
Combine Different Word files into one file and update Table of Content
|
tejaspareek | Word VBA | 4 | 11-04-2014 05:50 AM |
Please help me to combine these code together
|
lbf200n | Word VBA | 3 | 12-09-2012 04:22 PM |
How to combine many word files in one file but to have correct pages numbers and tabl
|
Jamal NUMAN | Word | 6 | 04-20-2011 02:32 PM |
Combine pst files?
|
markg2 | Outlook | 2 | 04-26-2010 03:09 PM |