Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Prevent overwriting a file
The code below is triggered by a command1 button on on UserForm1. It saves
the document with a name derived by combining data in certain cells. My problem is if that document name already exists. I do not want the user to have the option of replacing the original file or renaming the current file. I want a MsgBox which tells them that the file already exists. Once the MsgBox is dismissed I want UserForm1 to reappear so they can select a new date. Private Sub CommandButton1_Click() Dim myRange As Range Dim myDate As Range Set myRange = Worksheets("Relief Board").Range("C3") Set myDate = Worksheets("Relief Board").Range("C4") Protection.unprotect_all_sheets myRange.Value = "" myDate.Value = Calendar1.Value Protection.protect_all_sheets ActiveWorkbook.SaveAs Filename:="P:\AA Exception\ " & Worksheets("Relief Board").[B3].Value & ", " & Worksheets("Relief Board").[D3].Value & "_Exception Sheet", _ FileFormat:=xlOpenXMLWorkbookMacroEnabled, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Unload StartNewDay End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
prevent cell overwriting | Excel Worksheet Functions | |||
How to prevent overwriting of file ? | Excel Programming | |||
Prevent user from overwriting file | Excel Programming | |||
prevent users from overwriting other users data | Excel Worksheet Functions | |||
overwriting a file | Excel Programming |