![]() |
Need to test for file presence
I have a macro that looks for a specfic file in a directory. It opens
the file and then does some other stuff. What I want to do is test to see if the file is present or not. I think I should use an If Then Else statement, but I'm not sure how to test if the file Workbooks.OpenText Filename:= "pathToFile\pobcinv is successful. If Workbooks.OpenText Filename:= "pathToFile\pobcinv" is successfull Then 'Statements Else T.I.A. Grant |
Need to test for file presence
This is some code I wrote to check for a file on a disk. If you change the
LookIn directory and the Filename then you can setup any "Then" statement you want. Set fs = Application.FileSearch With fs .LookIn = "A:\" .Filename = "GLMISC.txt" If .Execute 0 Then "Grant" wrote: I have a macro that looks for a specfic file in a directory. It opens the file and then does some other stuff. What I want to do is test to see if the file is present or not. I think I should use an If Then Else statement, but I'm not sure how to test if the file Workbooks.OpenText Filename:= "pathToFile\pobcinv is successful. If Workbooks.OpenText Filename:= "pathToFile\pobcinv" is successfull Then 'Statements Else T.I.A. Grant |
Need to test for file presence
Thanks. I got that to work.
"kbrand" wrote in message ... This is some code I wrote to check for a file on a disk. If you change the LookIn directory and the Filename then you can setup any "Then" statement you want. Set fs = Application.FileSearch With fs .LookIn = "A:\" .Filename = "GLMISC.txt" If .Execute 0 Then "Grant" wrote: I have a macro that looks for a specfic file in a directory. It opens the file and then does some other stuff. What I want to do is test to see if the file is present or not. I think I should use an If Then Else statement, but I'm not sure how to test if the file Workbooks.OpenText Filename:= "pathToFile\pobcinv is successful. If Workbooks.OpenText Filename:= "pathToFile\pobcinv" is successfull Then 'Statements Else T.I.A. Grant |
Need to test for file presence
If Len(Dir$("pathToFile\povcinv") < 0 Then Workbooks.OpenText Filename:= "pathToFile\pobcinv" |
All times are GMT +1. The time now is 01:56 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com