G
Guest
This should be simple, but I must be simple:
fs.FileExists() and Dir() both work differently with variable versus value
of variable.
In my code, I assign
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
and I assign a value to str_ftp_ToFile.
I break where I'm trying to see if the file (value of str_ftp_ToFile) exists
and open the immediate window. In the Immediate window, I type what you see
following the ? including the comment after '
You can see what vba gives me in the line after:
----------------
? str_ftp_ToFile 'gives me the correct value for the file name:
"Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate 2007-08-31\rpt402_735.csv"
? fs.FileExists("Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate
2007-08-31\rpt402_735.csv") 'and it gives me Correct Answer True:
True
? fs.FileExists(str_ftp_ToFile) 'and it gives me Incorrect Answer when I
use the variable:
False
? str_ftp_ToFile 'and it still gives me the same value for the file
name:
"Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate 2007-08-31\rpt402_735.csv"
? Dir("Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate 2007-08-31\rpt402_735.csv")
'and Dir() gives me:
rpt402_735.csv
? Dir(str_ftp_ToFile)
' and I get Run-time error '52': Bad file name or number
What am I missing?
Why, when I paste the value of the variable into these functions, does it
give me an answer different from when I use the variable?
The variable is dimensioned str_ftp_ToFile As String.
Thank you
George
fs.FileExists() and Dir() both work differently with variable versus value
of variable.
In my code, I assign
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
and I assign a value to str_ftp_ToFile.
I break where I'm trying to see if the file (value of str_ftp_ToFile) exists
and open the immediate window. In the Immediate window, I type what you see
following the ? including the comment after '
You can see what vba gives me in the line after:
----------------
? str_ftp_ToFile 'gives me the correct value for the file name:
"Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate 2007-08-31\rpt402_735.csv"
? fs.FileExists("Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate
2007-08-31\rpt402_735.csv") 'and it gives me Correct Answer True:
True
? fs.FileExists(str_ftp_ToFile) 'and it gives me Incorrect Answer when I
use the variable:
False
? str_ftp_ToFile 'and it still gives me the same value for the file
name:
"Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate 2007-08-31\rpt402_735.csv"
? Dir("Y:\0Costpoint\PPDs\2007\P08_Aug\Paydate 2007-08-31\rpt402_735.csv")
'and Dir() gives me:
rpt402_735.csv
? Dir(str_ftp_ToFile)
' and I get Run-time error '52': Bad file name or number
What am I missing?
Why, when I paste the value of the variable into these functions, does it
give me an answer different from when I use the variable?
The variable is dimensioned str_ftp_ToFile As String.
Thank you
George