Trying to create code that stop's saving over a file based upon an event


Posted by Would appreciate it on February 05, 2002 12:22 PM

What I'm trying to do is write a small code that basically
Stops Excel from saving over a file & forces the user to
save it under a different name.

Here's my feeble attempt, but I don't seem to getting very
far
*****************************************************
Dim kill_close As String

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
kill_close = "NONONO"
If kill_close = "NONONO" Then
MsgBox "Kill"
Stop
End If
End Sub
************************************************
Thxs for the help

Posted by Juan Pablo G. on February 05, 2002 12:52 PM

Try with this condition

Sub Test()
Dim MyName
MyName = Application.GetSaveAsFilename
If MyName = False then Exit Sub
If Dir(MyName) <> "" then
MsgBox "File already exists"
Exit Sub
else
ThisWorkbook.SaveAs MyName
End If
End Sub


Juan Pablo G.



Posted by Would appreciate it on February 05, 2002 3:06 PM

Thxs Juan Pablo G. - Looks good, but


to save the file - trying to stop that as well

Thxs

Try with this condition