' GNZVBǍĂяoiPDF+PDF.exej
'@@Est@C̓GNZVBÃubNƓtH_ɒuĂB
'@@EPDF̓ubNƓtH_̒̃tH_ɓĂB
'@@EꂽPDF̓ubNƓtH_ɏo͂܂B
'@@EubNSheet1B1Zɓ͗ptH_AB2Zɏo̓t@Cw肵܂B
'@@E}N"MergePDF"sPDF܂B
'@@Ẽt@ĆAt@C".txt"폜΃C|[gł܂B

Attribute VB_Name = "ModuleX"
Option Explicit

Sub MergePDF()
    Dim exitCode As Long
    Dim exePath As String, arg1 As String, arg2 As String
    Dim cmd As String

    ' st@C̃pXGNZVBÃubNƓɐݒ
    exePath = ThisWorkbook.Path & "\PDF+PDF.exe"

    ' Sheet1B2Zo̓t@C擾
    arg1 = ThisWorkbook.Path & "\" & Worksheets("Sheet1").Range("B2").Value

    ' Sheet1B1Z͗ptH_擾
    arg2 = ThisWorkbook.Path & "\" & Worksheets("Sheet1").Range("B1").Value

    ' pXɃXy[X\̂ŁAK "" ň͂
    cmd = """" & exePath & """" & " " _
        & """" & arg1 & """" & " " _
        & """" & arg2 & """"

    ' sƏIR[h̎擾
    exitCode = CreateObject("WScript.Shell").Run(cmd, 0, True)

    ' sʂ̕\
    Select Case exitCode
    Case 5
        MsgBox "ł܂ł"
    Case 4
        MsgBox "t@C܂"
    Case 3
        MsgBox "tH_܂"
    Case 2
        MsgBox "o͖dŒ~"
    Case 1
        MsgBox "͂܂"
    Case Else
        MsgBox "Ɍ܂"
    End Select
End Sub

