Quick way to convert all images in folder to the same extension type? RRS feed

  • Question

  • After saving a word doc as a filtered HTML file I want the images folder to be in ALL .jpg or .png extension..is there a way to convert them all to .png, preferably? I know you can individually open them and resave them with a diff extension but I want a fast way to do this by writing code into my macro.


    Friday, May 24, 2013 10:35 PM

All replies

  • I use a program call ImageMagick (free).  It has a .com interface and you can call it from VBA or issue command line calls.  It is easy to call and convert images.  I also use it to scale images and change resolution.  Remember to add reference to .com object.  The format is specified by the file type.

    Function ResizeImg(ByVal From As String, ByVal to As String)

    Dim img As Object
    Set img = CreateObject("ImageMagickObject.MagickImage.1")
    msg =  img.Convert(From,to)
    end function

    • Edited by mogulman52 Saturday, May 25, 2013 3:51 PM
    • Proposed as answer by Shasur Monday, May 27, 2013 4:50 AM
    Saturday, May 25, 2013 3:33 PM
  • What do you mean by I need to add reference to .com object? How can I do that? Specifically, where in this code do I add reference to my images/their path? Do I need to upload the images to the website?

    Tuesday, May 28, 2013 3:05 PM