Detect file.

H

Heera Chavan

Hi

Below mentioned is my macro.
I want to see an access file is available on a path or not.

Sub team()

Dim mypath As String
Dim Fpath As String
Dim Fname As String

Fpath = ThisWorkbook.Sheets("Team3").Range("A1").Value ' the value is
"C:\Documents and Settings"
Fname = ThisWorkbook.Sheets("Team3").Range("A2").Value ' the value is "Team"

mypath = Fpath & "\" & Fname

If Dir(mypath) = "" Then
MsgBox "Network is disconnect or the required file is not available on
path.", vbInformation
Exit Sub
End If

end sub
 
F

FSt1

hi.
what problems are you having? error messages?
i see 1 potential problem with Fname. team? shouldn't that be team.xls

regards
FSt1
 
J

Jacob Skaria

The file extension is missing. Try below code.

Sub team()

Dim mypath As String
Dim Fpath As String
Dim Fname As String

Fpath = ThisWorkbook.Sheets("Team3").Range("A1").Value
Fname = ThisWorkbook.Sheets("Team3").Range("A2").Value
mypath = Fpath & "\" & Fname & "<extension>"
If Dir(mypath, vbNormal) = "" Then
MsgBox "Network is disconnect or the required file is not available on
path.", vbInformation
Exit Sub
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top