|
-
Apr 6th, 2000, 08:50 AM
#1
Thread Starter
Lively Member
I want to overwrite a file if it already exists, with an
"example.txt already exists, overwrite existing file?" MsgBox prompt first. When I save an existing file now, it just names it "example2.txt". How do I do this?
-
Apr 6th, 2000, 08:00 PM
#2
Lively Member
Try the following code (you have to add Microsoft Scripting Runtime (SCRRUN.DLL) in Project|References).
Dim fs As FileSystemObject
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("c:\example1.txt") Then
If MsgBox("example.txt already exists, overwrite existing file?", vbYesNo) = vbYes Then
fs.DeleteFile "c:\example1.txt"
' Save the file using example1.txt
Else
' Ask for another name?
End If
Else
' Save the file using example1.txt
End If
Complete the code acording to your needs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|