Home Image-Pro Plus Automation with Macros

Is there a way to test if a directory/folder exists?

Hi,

I have an AutoPro function (below) which saves the current image to a file. The IPBasic "Dir" function can be used to test if a file exists, but is there any way to test for existence of a folder (ImageFileFolder)?
 

thanks,
Kathy


Private Function Save_Image_File(Doc_ID, ScaleNum, ImageFileName)
' save the current scale image to TIF format file with all annotations
'
Dim ImageFilePath As String
If InStrRev(ImageFileFolder,"\") <> Len(ImageFileFolder) Then ImageFileFolder = ImageFileFolder & "\"

ImageFilePath = ImageFileFolder & ImageFileName & ScaleNum & ".JPG"

  ret = IpWsSaveEx(ImageFilePath, "TIF", 6, 8) '8-BPP TIF format using LZW compression

Save_Image_File = ret

End Function

Best Answer

  • Answer ✓

    Kathy,

    You can use the VB commands.  In my example below I use "ChDir" to change to a directory.  If that directory does not exist the command will give an error.  In my example I use error trapping to let me know that the command errored (meaning the directory does not exist).

     

     

    Sub Quick_Check()
     On Error GoTo NoDir
      ChDir "c:\vern"
      Exit Sub
     NoDir: Debug.Print "Directory does not exist"
    End Sub

Answers

Sign In or Register to comment.