ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Does file exist? (https://www.excelbanter.com/excel-programming/305007-does-file-exist.html)

ianripping[_81_]

Does file exist?
 
Is there a simple code for..

Does C:\fILE.XLS exist? if so then msgbox("Overwirte") else

--
Message posted from http://www.ExcelForum.com


Amedee Van Gasse[_3_]

Does file exist?
 
ianripping wrote:

Is there a simple code for..

Does C:\fILE.XLS exist? if so then msgbox("Overwirte") else _


Check out Scripting.FileSystemObject

--
To top-post is human, to bottom-post and snip is sublime.

Norman Jones

Does file exist?
 
Hi Ian,

Look at the Dir function.

For example:

If Len(Dir("C:\Test.xls")) 0 Then
'File found, Do something
Else
'File not found, Do something else
End If


---
Regards,
Norman


"ianripping " wrote in message
...
Is there a simple code for..

Does C:\fILE.XLS exist? if so then msgbox("Overwirte") else _


---
Message posted from http://www.ExcelForum.com/




Damien McBain

Does file exist?
 
Is there a simple code for..

Does C:\fILE.XLS exist? if so then msgbox("Overwirte") else _


Some code a mate gave me for this purpose:

Function isdasuckerthere(dapath As String, dafile As String) As Boolean
Dim foundfile As String
isdasuckerthere = False
foundfile = Dir(dapath & dafile)
If Not foundfile = "" Then isdasuckerthere = True
End Function

Sub example()
If isdasuckerthere(Cells(1, 1), "win.ini") Then
MsgBox "Found"
Else
MsgBox "Nope"
End If
End Sub

You can use this function (isdasuckerthere) in a worksheet or manipulate the
logic to use in VBA.

Damo



ianripping[_82_]

Does file exist?
 
Thanks both work grea

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:00 PM.

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