PDA

View Full Version : Solved: "If FileExist" isn't seeing the file



DanOfEarth
04-03-2011, 04:35 PM
I know the Darn file I'm checking for below is there and the directory is correct....yet it keeps triggering the second message box below ("The file DOES NOT EXIST"")


RecipeFullName = "C:\Documents and Settings\Dan\Desktop\Project - Eat Like a King\Charbroiled_Pork.xlsm"
If Dir("RecipeFullNameLong") <> "" Then
MsgBox "The file already exists! Either rename of check for duplicates"
Exit Sub
Else
MsgBox "The file DOES NOT EXIST"
Exit Sub
End If


I've even used the Function method of checking on the file...same thing. gotta be something simple. I've "checked If file Exist" millions of times in subs. Why now.

mbarron
04-03-2011, 06:14 PM
You've changed your variable into a string. Get rid of the quotes around RecipeFullName in:

If Dir("RecipeFullNameLong") <> "" Then

DanOfEarth
04-04-2011, 09:14 AM
Ahh...that silly syntax. Thank you very much. Earlier when I checked that it didn't fix it, but I think it was flagging something else.