Sub fsoobject()
Dim fso As New FileSystemObject, f As Folder, sf As Folder, myFile As File
Set f = fso.GetFolder("C:\Users\jpmehta\Desktop")
Dim File
For Each File In f.Files
If File.Name = "Done.PNG" Then
Call Shell("Explorer.exe """ & File.Path & """", vbNormalFocus)
Exit For
End If
Next
End Sub
Sub fsoobject()
Dim fso As New FileSystemObject, f As Folder, sf As Folder, myFile As File
Set f = fso.GetFolder("C:\Users\jpmehta\Desktop")
'For Each sf In f.SubFolders
' For Each mySubFolder In sf.SubFolders
' For Each myFile In mySubFolder.Files
' If myFile.Name Like "Done" Then
' MsgBox myFile.Name
' Exit For
' End If
' Next
'
' MsgBox "Else"
' Next
'Next
Dim File
For Each File In f.Files
If File.Name = "Done.PNG" Then
Call Shell("Explorer.exe """ & File.Path & """", vbNormalFocus)
Exit For
End If
Next
End Sub
Well, I searched a bit, and found this keyword "Shell" to open a file. On applying this code, now it executes successfully...