Does file exist?

  • Thread starter Thread starter ianripping
  • Start date Start date
I

ianripping

Is there a simple code for..

Does C:\fILE.XLS exist? if so then msgbox("Overwirte") else
 
ianripping said:
Is there a simple code for..

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

Check out Scripting.FileSystemObject
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top