ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if a File Exists (https://www.excelbanter.com/excel-programming/388542-check-if-file-exists.html)

Ray Clark[_2_]

Check if a File Exists
 
I need to check if a file exists before creating a new file.

Jim Cone

Check if a File Exists
 

Function IsItThere()
Dim blnFile As Boolean
Dim strPath As String

strPath = "C:\Program Files\ahead\Nero\Boo.wav"
blnFile = Len(Dir(strPath))
MsgBox blnFile
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Ray Clark"
wrote in message
I need to check if a file exists before creating a new file.

Ray Clark[_2_]

Check if a File Exists
 
Thanks Jim great help.

"Jim Cone" wrote:


Function IsItThere()
Dim blnFile As Boolean
Dim strPath As String

strPath = "C:\Program Files\ahead\Nero\Boo.wav"
blnFile = Len(Dir(strPath))
MsgBox blnFile
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Ray Clark"
wrote in message
I need to check if a file exists before creating a new file.


Curt

Check if a File Exists
 
If ("C:\Parade\zzz.txt") Then
Call KillFile
exit sub
' Else
End If
Missing something Want if file exists call KillFile if not by pass and
continue

"Jim Cone" wrote:


Function IsItThere()
Dim blnFile As Boolean
Dim strPath As String

strPath = "C:\Program Files\ahead\Nero\Boo.wav"
blnFile = Len(Dir(strPath))
MsgBox blnFile
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Ray Clark"
wrote in message
I need to check if a file exists before creating a new file.


Jim Cone[_2_]

Check if a File Exists
 
Sub WhatAmIDoing()
If IsItThere("C:\Parade\zzz.txt") Then
Call KillFile
Exit Sub
Else
'do something
End If
'more somethings
End Sub

Function IsItThere(ByRef strPath As String) As Boolean
Dim blnFile As Boolean
blnFile = Len(Dir(strPath))
IsItThere = blnFile
End Function
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Curt"
wrote in message
If ("C:\Parade\zzz.txt") Then
Call KillFile
exit sub
' Else
End If
Missing something Want if file exists call KillFile if not by pass and
continue



"Jim Cone" wrote:
Function IsItThere()
Dim blnFile As Boolean
Dim strPath As String

strPath = "C:\Program Files\ahead\Nero\Boo.wav"
blnFile = Len(Dir(strPath))
MsgBox blnFile
End Function
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Ray Clark"
wrote in message
I need to check if a file exists before creating a new file.



All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com