Link Search Menu Expand Document

Merge PDF Documents - Microsoft Excel

PDF Extractor SDK sample in Microsoft Excel demonstrating ‘Merge PDF Documents’

MergePDFs_VBA.txt
' IMPORTANT: This demo uses VBA so if you have it disabled please temporary enable
' by going to Tools - Macro - Security.. and changing the security mode to ""Medium""
' to Ask if you want enable macro or not. Then close and reopen this Excel document

' You should have evaluation version of the ByteScout SDK installed to get it working - get it from https://bytescout.com

' If you are getting error message like
' "File or assembly named Bytescout SDK, or one of its dependencies, was not found"
' then please try the following:
'
' - Close Excel
' - (for Office 2003 only) download and install this hotfix from Microsoft:
' http://www.microsoft.com/downloads/details.aspx?FamilyId=1B0BFB35-C252-43CC-8A2A-6A64D6AC4670&displaylang=en
'
' and then try again!
'
' If you have any questions please contact us at http://bytescout.com/support/ or at support@bytescout.com
                            

'==============================================
'References used
'=================
'Bytescout PDF Extractor SDK
'
' IMPORTANT:
' ==============================================================
'1) Add the ActiveX reference in Tools -> References
'
'==================================================================


Private Sub CommandButton1_Click()

' Create Bytescout.PDFExtractor.DocumentMerger object
' Set extractor = CreateObject("Bytescout.PDFExtractor.DocumentMerger")
Dim merger As New Bytescout_PDFExtractor.DocumentMerger

merger.RegistrationName = "demo"
merger.RegistrationKey = "demo"

Dim wb As Workbook
Dim ws As Worksheet

Set wb = ActiveWorkbook
Set ws = wb.Sheets("Sheet1")

Dim sample1FilePath
sample1FilePath = CStr(ws.Range("B1").Value)

Dim sample2FilePath
sample2FilePath = ws.Range("B2").Value

Dim outputFilePath
outputFilePath = ws.Range("B3").Value

' Load sample PDF document
merger.Merge2 sample1FilePath, sample2FilePath, outputFilePath

MsgBox "Result File Generated Successfully!"

Set merger = Nothing

End Sub

Download Source Code (.zip)

Return to the previous page Explore PDF Extractor SDK