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. #13
    Quote Originally Posted by jdelano View Post
    Below the for loop that calls the convert code. You could check for the existence of the converted PDF file(s), if it's there then delete the image file the PDF was created from:

    ' delete the images that have been converted to PDFs
    For j = 1 To col.Count
        If Dir("C:\MIHAI\DOC\ASIG\DOSARE\X\" & Replace$(col(j), ".jpg", ".pdf")) <> "" Then
            Kill "C:\MIHAI\DOC\ASIG\DOSARE\X\" & col(j)
        End If
    Next
    Hi jdelano and thanks for your reply

    i didnt upgraded my correct code, sorry
    so I use this code to convert all jpg into 1 single pdf


    Option Explicit
    
    Public Sub subTestMagick()
        Dim inPath As String
        Dim outPath As String
         inPath = "C:\MIHAI\DOC\ASIG\DOSARE\*.*"
        outPath = "C:\MIHAI\DOC\ASIG\DOSARE\Outpu.pdf"
        Call ConvertJpgToPdfUsingMagick(inPath, outPath)
    End Sub
    
    
    Sub ConvertJpgToPdfUsingMagick(ByVal inputImagePath As String, ByVal outputPdfPath As String)
        Dim command As String
        command = "C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe convert -resize 1240x1753 -extent 1240x1753 -gravity center -units _
        PixelsPerInch -density 150x150 """ & inputImagePath & """ """ & outputPdfPath & """"
        Shell command, vbHide
    End Sub
    So, after i run this code with a macro, I need to delete the initial pdf files.
    How can I adapt your code to this ?

    Thanks,
    God Bless!
    Last edited by Aussiebear; 12-24-2024 at 05:49 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
  •