Reputation: 363
I am trying to find an existing file in a folder location
Current Code:
Dim FileExistsbol As Boolean
Dim stFileName As String
stFileName = "H:\Test File.txt"
stFileName = Trim(stFileName)
FileExistsbol = dir(stFileName) <> vbNullString
If FileExistsbol Then Kill stFileName
Error:
The error message is: Type Mismatch VBA debugs on this line:
FileExistsbol = dir(stFileName) <> vbNullString
The file does exist so unsure how to resolve this - Any ideas?
Upvotes: 0
Views: 64
Reputation: 275
I would get rid of the FileExistsbol variable and then just do something like:
If Dir(stFileName) <> "" Then
Kill stFileName
End If
Upvotes: 2