ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Preventing file overwriting (https://www.excelbanter.com/excel-programming/428588-preventing-file-overwriting.html)

TPJoseph

Preventing file overwriting
 
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

AltaEgo

Preventing file overwriting
 
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



TPJoseph

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





All times are GMT +1. The time now is 03:34 AM.

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