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: 103
Default Custom Error Message

Here is the problem...I tell the workbook where to save and with what name
using code, part of the file name is a date entered by the user. If the user
enters the same date then I want to give them the option of overwriting the
file or canceling the save. I have tried the following code and can't get it
to work properly. It works great if I put in Application.DisplayAlerts =
False and just allow it to overwrite the existing file, but if there is
already a lot of info in that file that would not be good. I would like it to
be a critical message and they can either choose yes or no, if they choose
yes then it would resume the save, if no then I will put some code in so that
certain sheets are shown. Any help is greatly appreciated.

On Error GoTo SaveOrNot

ActiveWorkbook.SaveAs Filename:= _
myFileName, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

MsgBox "File Saved to " & myFileName
End If
Application.ScreenUpdating = True

SaveOrNot:
Dim Res As Long
Res = MsgBox("A File With This Name Already Exists In This Location! Do You
Want To Replace It?", vbYesNo)
If Res = 6 Then
Resume
ElseIf Res = 7 Then
End If
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
Custom Views Error Message Phippsy Excel Discussion (Misc queries) 3 September 9th 08 01:42 PM
replace VBA run-time error message with custom message BEEJAY Excel Programming 13 July 14th 06 03:59 PM
Custom error-message for MatchRequired ComboBox Gert-Jan Excel Programming 1 June 21st 06 09:51 PM
Replace Excel Message w/Custom Message Kevin R Excel Programming 1 May 18th 06 04:13 PM
Why error message when trying to display custom view? creativeops Excel Discussion (Misc queries) 2 January 9th 06 09:57 PM


All times are GMT +1. The time now is 06:41 PM.

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

About Us

"It's about Microsoft Excel"