I am working in making Access VBA code which needs another software, so first I need to check if this software is installed in the PC or not before I implement my codes.
I found one way to do this with searching for the directory, but then I figure out that I may have a different version, and also this directory may change based on the users, as you know when you install something it ask u if u want to change the default location, and sometimes the users do this, so I would like to avoid this!!! I want my code to be very perfect and consider all scenario.
My Question now, can I just search for the file without knowing the file location (the file path)... Normally the EXE file is the same for all version, so I want to search for this EXE file without knowing the path, just normal search.
This is the function that I have used for now and it works very fine...
Expand|Select|Wrap|Line Numbers
- Public Function File_Exists(ByVal sPathName As String, Optional Directory As Boolean) As Boolean
- 'Returns True if the passed sPathName exist
- 'Otherwise returns False
- On Error Resume Next
- If sPathName <> "" Then
- If IsMissing(Directory) Or Directory = False Then
- File_Exists = (Dir$(sPathName) <> "")
- Else
- File_Exists = (Dir$(sPathName, vbDirectory) <> "")
- End If
- End If
- End Function
Regards