Sending String Variable to Command Line RRS feed

  • Question

  • Hi!

    I am trying to send a variable string which is a filename, to the command line for ImageMagick to convert from a .tiff to .jpeg. Is there anyway to go about this? So far I have

    Sub convert()
    Dim intFile As Integer
    Dim import, export As String

    intFile = FreeFile()

    import = "C:\Documents and Settings\ct-xray\My Documents\new\ScatterFreeRadiograph90.tif"
    export = "C:\Documents and Settings\ct-xray\My Documents\new\ScatterFreeRadiograph90.jpg"

    Open "C:\WINDOWS\Temp\MyBatchFile.bat" For Output As #intFile
    Print #intFile, "CD C:\Program Files (x86)\ImageMagick-6.8.5-Q16"
    Print #intFile, "convert import export"

    Close #intFile
    End Sub

    Thanks in advance! I am writing in a macro on Excel 2007
    Wednesday, June 12, 2013 12:44 PM


  • If you are creating a file, you would want to use

    Print #intFile, "convert " & import & " " & export

    since import and export are variables containing the string that you want to use.

    Have you looked at Shell? Something like

    Shell "C:\Program Files (x86)\ImageMagick-6.8.5-Q16\ImageMagick.exe convert " & import & " " & export

    Wednesday, June 12, 2013 1:44 PM