Results 1 to 17 of 17

Thread: Convert all jpg and pdf files from folder into 1 single pdf with same width

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    you can use ImageMagick?
    ImageMagick – Download
    Private Sub tt()
    Const conType As String = "*.jpg"
    Dim col As New Collection
    Dim sFile As String, j As Integer
    Dim path As String, ext As String
    ' put the PATH of the jpgs here!
    path = Environ$("userprofile") & "\documents\"
    sFile = Dir$(path & conType)
    Do Until Len(sFile) = 0
        j = j + 1
        col.Add Item:=sFile, Key:=j & ""
        sFile = Dir$
    Loop
    For j = 1 To col.Count
        Call ConvertJpgToPdfUsingMagick(col(j), Replace$(col(j), ".jpg", ".pdf"))
    Next
    End Sub
    
    
    Sub ConvertJpgToPdfUsingMagick(ByVal inputImagePath As String, ByVal outputPdfPath As String)
        'Dim inputImagePath As String
        'Dim outputPdfPath As String
        Dim command As String
        ' Set the paths
        'inputImagePath = "C:\Path\To\Input\Image.jpg"
        'outputPdfPath = "C:\Path\To\Output\Output.pdf"
        ' Build the command
        command = "C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe convert """ & inputImagePath & """ """ & outputPdfPath & """"
        ' Execute the command
        Shell command, vbHide
    End Sub
    Last edited by Aussiebear; 12-24-2024 at 05:44 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •