JHB
2012-07-11 16:59:55 UTC
Hi:
I am attmpting to find out if a file exists using a routine copied
from someone else in the form of a visual baseic module. I am using a
puublic funcytion hat says the following:
Public Function FileFolderExists(strFullPath As String) As Boolean
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Check if a file or folder exists
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then
FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
To call it, I am using a tailored function as follows:
Public Sub SchedImportTHERE()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Test if directory exists
Sheets("FILELIST").Select
Range("D2").Select
Filename = ActiveCell()
If FileFolderExists(Filename) Then
MsgBox "File exists!"
Else
MsgBox "File does not exist!"
End If
End Sub
The Contents of cell D2 is a constructed file reference based on
history. My problem is that while the actual value in D2 is 100%
correct, the way that I have set up the actual call to the
FileFolderExists function is wrong!
I know that it is in the way I have constructed the call and that
(Filename) is wrong. I just do not know how to fix it! If I substitute
the actual file address into Filename, ("C:/download/names.xls") it
works fine.
Help please
John baker
I am attmpting to find out if a file exists using a routine copied
from someone else in the form of a visual baseic module. I am using a
puublic funcytion hat says the following:
Public Function FileFolderExists(strFullPath As String) As Boolean
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Check if a file or folder exists
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then
FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
To call it, I am using a tailored function as follows:
Public Sub SchedImportTHERE()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Test if directory exists
Sheets("FILELIST").Select
Range("D2").Select
Filename = ActiveCell()
If FileFolderExists(Filename) Then
MsgBox "File exists!"
Else
MsgBox "File does not exist!"
End If
End Sub
The Contents of cell D2 is a constructed file reference based on
history. My problem is that while the actual value in D2 is 100%
correct, the way that I have set up the actual call to the
FileFolderExists function is wrong!
I know that it is in the way I have constructed the call and that
(Filename) is wrong. I just do not know how to fix it! If I substitute
the actual file address into Filename, ("C:/download/names.xls") it
works fine.
Help please
John baker