I have to find if an exe file exists using Visual Basic 6. The file can be in any path or drive.I should check if the file is present without specifying the path explicitly.This is similar to the Find file option in windows. How do i write VB code for this.I have written the code to identify the drives present.
Private Sub Command1_Click()
Dim myfile, mypath, myname, nextPath
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d In dc
s = d.DriveLetter
If s <> "A" Then
mypath = "" & s & ":\Program Files\Microsoft Office\Office\"
myname = Dir(mypath)
Do While myname <> ""
'If myname <> "." & myname <> ".." Then
'If (GetAttr(mypath & myname) And vbDirectory) = vbDirectory Then
If myname = "EXCEL.EXE" Then MsgBox myname & " - Excel present"
If myname = "WINWORD.EXE" Then MsgBox myname & " - Word Present"
myname = Dir