LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
prevent cell overwriting connect4u Excel Worksheet Functions 1 December 22nd 09 01:28 PM
How to prevent overwriting of file ? [email protected] Excel Programming 4 March 19th 08 01:09 PM
Prevent user from overwriting file peter.thompson[_45_] Excel Programming 5 January 14th 06 12:31 PM
prevent users from overwriting other users data [email protected] Excel Worksheet Functions 0 April 17th 05 08:18 PM
overwriting a file Jordan Shoderu Excel Programming 4 August 6th 04 11:46 AM


All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"