View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
TPJoseph TPJoseph is offline
external usenet poster
 
Posts: 8
Default Preventing file overwriting

Thanks.

"AltaEgo" wrote:

Try this way:

Function FileExists(FName As String) As Boolean
FileExists = (Dir(Fname) "")
End Function


Use as follows

If FileExists("c:\test\test.xls") Then
'
' MsgBox "File exists"
'
Else
' whatever
End If


--
Steve

"TPJoseph" wrote in message
...
I am using the following to check for the presence of a file and if
presnet,
prevent it from copying over it. It does not seem to work.

Can someone please advise the proper way to accomplish this? Some example
code would be greatly appreciated.

Thanks.

If Dir("ArchivePathFilenameStr") = "" Then
FileCopy Source:=PathFilenameStr, Destination:=ArchivePathFilenameStr
Else
End If