Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Need to test for file presence


If Len(Dir$("pathToFile\povcinv") < 0 Then
Workbooks.OpenText Filename:= "pathToFile\pobcinv"
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I test a range of cells for the presence of a border? PFB Excel Worksheet Functions 7 November 10th 08 05:19 AM
Detect Presence Formula Ken Excel Worksheet Functions 6 September 12th 06 06:43 PM
please help me mark their presence. hirendra7158 Excel Worksheet Functions 3 March 13th 06 10:46 PM
count their presence hirendra7158 Excel Worksheet Functions 1 March 13th 06 08:41 PM
Signaling the presence of a password Geert Nauta[_3_] Excel Programming 3 October 6th 04 04:30 PM


All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"