Dir Funtion?

Tommy B

Registered User.
Local time
Today, 23:01
Joined
Feb 26, 2001
Messages
43
Hi Guys,

Well I'm bumbling along with my vba and have had some success (mainly due to the patience and indulgance of fellow members:p ). However I have a hit a problem with the Dir function, I know I must be wrong but I would really appreciate somebody showing me the error of my ways.

I'm getting a type mismatch run-time error 13....can anyone explain what's wrong with my code?

Cheers,

Tommy B

Public sub test()
Dim retval


If Dir("C:\leads_folder\daily_declines\dailydone.txt") Then
Kill ("C:\leads_folder\daily_declines\dailydone.txt")
retval = shell("c:\leads_folder\daily_declines\dailyconversion(tom).bat", vbMinimizedFocus)
While Not Dir("C:\leads_folder\daily_declines\dailydone.txt", vbNormal)
Wend
End If
End Sub
 
Dont worry its a easy mistake to make, the dir fucntion is a bit weird


try
Code:
If Dir("C:\leads_folder\daily_declines\dailydone.txt") Then 
Kill ("C:\leads_folder\daily_declines\dailydone.txt") 
retval = shell(" c:\leads_folder\daily_declines\dailyconversion(tom
).bat", vbMinimizedFocus) 
Do
        If Dir = "" Then
            Exit Do
            
        End If
Loop
End If 
End Sub




:cool:ShadeZ:cool:
 
Thank-You

Brilliant, thanks Shadez. Iwas close but no cigar :p

Thanks again for taking the time to help me out...much appreciated!

Cheers,

Tom. :D
 
The Dir function doesn't return a True/False value. It returns an empty string, or the name of a file or folder. So try this:

If Dir("C:\leads_folder\daily_declines\dailydone.txt") <> "" Then
Kill ("C:\leads_folder\daily_declines\dailydone.txt")
retval = shell(" c:\leads_folder\daily_declines\dailyconversion(tom
).bat", vbMinimizedFocus)
While Dir("C:\leads_folder\daily_declines\dailydone.txt", vbNormal) = ""
Wend
End If
End Sub

Instead of using Shell and then looping for a file name, you may want to consider using Shell and Wait:

http://www.mvps.org/access/api/api0004.htm

Hope this helps,
 
Peter D said:
The Dir function doesn't return a True/False value. It returns an empty string, or the name of a file or folder. So try this:

If Dir("C:\leads_folder\daily_declines\dailydone.txt") <> "" Then
Kill ("C:\leads_folder\daily_declines\dailydone.txt")
retval = shell(" c:\leads_folder\daily_declines\dailyconversion(tom
).bat", vbMinimizedFocus)
While Dir("C:\leads_folder\daily_declines\dailydone.txt", vbNormal) = ""
Wend
End If
End Sub

Instead of using Shell and then looping for a file name, you may want to consider using Shell and Wait:

http://www.mvps.org/access/api/api0004.htm

Hope this helps,


You have been beaten to it by a good 3 hours,


Oh and nice infiate loop.:rolleyes:
 

Users who are viewing this thread

Back
Top Bottom